forked from Vonage/vonage-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
/
developer_account_pricing.go
114 lines (100 loc) · 3.87 KB
/
developer_account_pricing.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package nexmo
import (
"fmt"
"net/http"
)
type GetOutboundPricingForCountryRequest struct {
Credentials
Country string `url:"country"`
}
type CountryPrices struct {
MT string `json:"mt"`
Country string `json:"country"`
Prefix string `json:"prefix"`
Name string `json:"name"`
Networks []NetworkPrice `json:"networks"`
}
// GetOutboundPricingForCountry requests pricing for a given country
func (s *DeveloperService) GetOutboundPricingForCountry(request GetOutboundPricingForCountryRequest) (*CountryPrices, *http.Response, error) {
s.authSet.ApplyAPICredentials(&request)
response := new(CountryPrices)
httpResponse, err := s.sling.New().
Get("account/get-pricing/outbound/").
QueryStruct(request).
ReceiveSuccess(response)
return response, httpResponse, err
}
type GetOutboundProductPricingRequest struct {
Credentials
Product string `url:"-"`
Country string `url:"country"`
}
type GetOutboundProductPricingResponse struct {
DialingPrefix string `json:"dialingPrefix"`
DefaultPrice string `json:"defaultPrice"`
Currency string `json:"currency"`
CountryDisplayName string `json:"countryDisplayName"`
CountryCode string `json:"countryCode"`
CountryName string `json:"countryName"`
Networks []NetworkDetails `json:"networks"`
}
type NetworkDetails struct {
Type string `json:"type"`
Price string `json:"price"`
Currency string `json:"currency"`
Ranges []int64 `json:"ranges"`
MNC string `json:"mnc"`
MCC string `json:"mcc"`
NetworkCode string `json:"networkCode"`
NetworkName string `json:"networkName"`
}
// GetOutboundProductPricing requests prices for a product in a given country
func (s *DeveloperService) GetOutboundProductPricing(request GetOutboundProductPricingRequest) (*GetOutboundProductPricingResponse, *http.Response, error) {
s.authSet.ApplyAPICredentials(&request)
response := new(GetOutboundProductPricingResponse)
httpResponse, err := s.sling.New().
Get(fmt.Sprintf("account/get-pricing/outbound/%s/", request.Product)).
QueryStruct(request).
ReceiveSuccess(response)
return response, httpResponse, err
}
type GetPrefixOutboundPricingRequest struct {
Credentials
Prefix string `url:"prefix"`
}
type GetPrefixOutboundPricingResponse struct {
Count int64 `json:"count"`
Prices []CountryPrices `json:"prices"`
}
type NetworkPrice struct {
Network string `json:"network"`
Code string `json:"code"`
MTPrice string `json:"mtPrice"`
}
// GetPrefixOutboundPricing requests outbound pricing for a given international prefix
func (s *DeveloperService) GetPrefixOutboundPricing(request GetPrefixOutboundPricingRequest) (*GetPrefixOutboundPricingResponse, *http.Response, error) {
s.authSet.ApplyAPICredentials(&request)
response := new(GetPrefixOutboundPricingResponse)
httpResponse, err := s.sling.New().
Get("account/get-prefix-pricing/outbound/").
QueryStruct(request).
ReceiveSuccess(response)
return response, httpResponse, err
}
// GetPhoneOutboundPricingRequest is the request object for DeveloperService.GetPhoneOutboundPricing
type GetPhoneOutboundPricingRequest struct {
// This is defined here because Product must not be serialized, and I haven't implemented that in the json-schema
Credentials
Phone string `url:"phone"`
Product string `url:"-"`
}
// GetPhoneOutboundPricing requests outbound pricing for a given phone number
func (s *DeveloperService) GetPhoneOutboundPricing(request GetPhoneOutboundPricingRequest) (*GetPhoneOutboundPricingResponse, *http.Response, error) {
s.authSet.ApplyAPICredentials(&request)
response := new(GetPhoneOutboundPricingResponse)
httpResponse, err := s.sling.New().
Get("account/get-phone-pricing/outbound/" + request.Product).
QueryStruct(request).
ReceiveSuccess(response)
return response, httpResponse, err
}