github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/mobile/mysterium/proposals.go (about) 1 /* 2 * Copyright (C) 2021 The "MysteriumNetwork/node" Authors. 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 package mysterium 19 20 import "encoding/json" 21 22 // GetCountries returns service proposals number per country from API. 23 // go mobile does not support complex slices. 24 func (mb *MobileNode) GetCountries(req *GetProposalsRequest) ([]byte, error) { 25 countries, err := mb.proposalsManager.getCountries(req) 26 if err != nil { 27 return nil, err 28 } 29 return json.Marshal(countries) 30 } 31 32 // GetProposals returns service proposals from API or cache. Proposals returned as JSON byte array since 33 // go mobile does not support complex slices. 34 func (mb *MobileNode) GetProposals(req *GetProposalsRequest) ([]byte, error) { 35 proposals, err := mb.proposalsManager.getProposals(req) 36 if err != nil { 37 return nil, err 38 } 39 return json.Marshal(proposals) 40 } 41 42 // GetProposalsByPreset returns service proposals by presetID. 43 func (mb *MobileNode) GetProposalsByPreset(presetID int) ([]byte, error) { 44 proposals, err := mb.proposalsManager.getProposals(&GetProposalsRequest{PresetID: presetID}) 45 if err != nil { 46 return nil, err 47 } 48 return json.Marshal(proposals) 49 }