/
subscription.go
375 lines (297 loc) · 14.9 KB
/
subscription.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved.
// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
// Code generated. DO NOT EDIT.
// OSP Gateway API
//
// This site describes all the Rest endpoints of OSP Gateway.
//
package ospgateway
import (
"encoding/json"
"fmt"
"github.com/oracle/oci-go-sdk/v65/common"
"strings"
)
// Subscription Subscription details object which extends the SubscriptionSummary
type Subscription struct {
// Subscription plan number.
SubscriptionPlanNumber *string `mandatory:"true" json:"subscriptionPlanNumber"`
// Subscription id identifier (OCID).
Id *string `mandatory:"false" json:"id"`
// Subscription plan type.
PlanType SubscriptionPlanTypeEnum `mandatory:"false" json:"planType,omitempty"`
// Start date of the subscription.
TimeStart *common.SDKTime `mandatory:"false" json:"timeStart"`
// Ship to customer account site address id.
ShipToCustAcctSiteId *string `mandatory:"false" json:"shipToCustAcctSiteId"`
// Ship to customer account role.
ShipToCustAcctRoleId *string `mandatory:"false" json:"shipToCustAcctRoleId"`
// Bill to customer Account id.
BillToCustAccountId *string `mandatory:"false" json:"billToCustAccountId"`
// Payment intension.
IsIntentToPay *bool `mandatory:"false" json:"isIntentToPay"`
// Currency code
CurrencyCode *string `mandatory:"false" json:"currencyCode"`
// GSI Subscription external code.
GsiOrgCode *string `mandatory:"false" json:"gsiOrgCode"`
// Language short code (en, de, hu, etc)
LanguageCode *string `mandatory:"false" json:"languageCode"`
// GSI organization external identifier.
OrganizationId *string `mandatory:"false" json:"organizationId"`
// Status of the upgrade.
UpgradeState SubscriptionUpgradeStateEnum `mandatory:"false" json:"upgradeState,omitempty"`
// This field is used to describe the Upgrade State in case of error (E.g. Upgrade failure caused by interfacing Tax details- TaxError)
UpgradeStateDetails SubscriptionUpgradeStateDetailsEnum `mandatory:"false" json:"upgradeStateDetails,omitempty"`
// Account type.
AccountType SubscriptionAccountTypeEnum `mandatory:"false" json:"accountType,omitempty"`
TaxInfo *TaxInfo `mandatory:"false" json:"taxInfo"`
// Payment option list of a subscription.
PaymentOptions []PaymentOption `mandatory:"false" json:"paymentOptions"`
PaymentGateway *PaymentGateway `mandatory:"false" json:"paymentGateway"`
BillingAddress *Address `mandatory:"false" json:"billingAddress"`
// Date of upgrade/conversion when planType changed from FREE_TIER to PAYG
TimePlanUpgrade *common.SDKTime `mandatory:"false" json:"timePlanUpgrade"`
// Date of upgrade/conversion when account type changed from PERSONAL to CORPORATE
TimePersonalToCorporateConv *common.SDKTime `mandatory:"false" json:"timePersonalToCorporateConv"`
}
func (m Subscription) String() string {
return common.PointerString(m)
}
// ValidateEnumValue returns an error when providing an unsupported enum value
// This function is being called during constructing API request process
// Not recommended for calling this function directly
func (m Subscription) ValidateEnumValue() (bool, error) {
errMessage := []string{}
if _, ok := GetMappingSubscriptionPlanTypeEnum(string(m.PlanType)); !ok && m.PlanType != "" {
errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for PlanType: %s. Supported values are: %s.", m.PlanType, strings.Join(GetSubscriptionPlanTypeEnumStringValues(), ",")))
}
if _, ok := GetMappingSubscriptionUpgradeStateEnum(string(m.UpgradeState)); !ok && m.UpgradeState != "" {
errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for UpgradeState: %s. Supported values are: %s.", m.UpgradeState, strings.Join(GetSubscriptionUpgradeStateEnumStringValues(), ",")))
}
if _, ok := GetMappingSubscriptionUpgradeStateDetailsEnum(string(m.UpgradeStateDetails)); !ok && m.UpgradeStateDetails != "" {
errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for UpgradeStateDetails: %s. Supported values are: %s.", m.UpgradeStateDetails, strings.Join(GetSubscriptionUpgradeStateDetailsEnumStringValues(), ",")))
}
if _, ok := GetMappingSubscriptionAccountTypeEnum(string(m.AccountType)); !ok && m.AccountType != "" {
errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for AccountType: %s. Supported values are: %s.", m.AccountType, strings.Join(GetSubscriptionAccountTypeEnumStringValues(), ",")))
}
if len(errMessage) > 0 {
return true, fmt.Errorf(strings.Join(errMessage, "\n"))
}
return false, nil
}
// UnmarshalJSON unmarshals from json
func (m *Subscription) UnmarshalJSON(data []byte) (e error) {
model := struct {
Id *string `json:"id"`
PlanType SubscriptionPlanTypeEnum `json:"planType"`
TimeStart *common.SDKTime `json:"timeStart"`
ShipToCustAcctSiteId *string `json:"shipToCustAcctSiteId"`
ShipToCustAcctRoleId *string `json:"shipToCustAcctRoleId"`
BillToCustAccountId *string `json:"billToCustAccountId"`
IsIntentToPay *bool `json:"isIntentToPay"`
CurrencyCode *string `json:"currencyCode"`
GsiOrgCode *string `json:"gsiOrgCode"`
LanguageCode *string `json:"languageCode"`
OrganizationId *string `json:"organizationId"`
UpgradeState SubscriptionUpgradeStateEnum `json:"upgradeState"`
UpgradeStateDetails SubscriptionUpgradeStateDetailsEnum `json:"upgradeStateDetails"`
AccountType SubscriptionAccountTypeEnum `json:"accountType"`
TaxInfo *TaxInfo `json:"taxInfo"`
PaymentOptions []paymentoption `json:"paymentOptions"`
PaymentGateway *PaymentGateway `json:"paymentGateway"`
BillingAddress *Address `json:"billingAddress"`
TimePlanUpgrade *common.SDKTime `json:"timePlanUpgrade"`
TimePersonalToCorporateConv *common.SDKTime `json:"timePersonalToCorporateConv"`
SubscriptionPlanNumber *string `json:"subscriptionPlanNumber"`
}{}
e = json.Unmarshal(data, &model)
if e != nil {
return
}
var nn interface{}
m.Id = model.Id
m.PlanType = model.PlanType
m.TimeStart = model.TimeStart
m.ShipToCustAcctSiteId = model.ShipToCustAcctSiteId
m.ShipToCustAcctRoleId = model.ShipToCustAcctRoleId
m.BillToCustAccountId = model.BillToCustAccountId
m.IsIntentToPay = model.IsIntentToPay
m.CurrencyCode = model.CurrencyCode
m.GsiOrgCode = model.GsiOrgCode
m.LanguageCode = model.LanguageCode
m.OrganizationId = model.OrganizationId
m.UpgradeState = model.UpgradeState
m.UpgradeStateDetails = model.UpgradeStateDetails
m.AccountType = model.AccountType
m.TaxInfo = model.TaxInfo
m.PaymentOptions = make([]PaymentOption, len(model.PaymentOptions))
for i, n := range model.PaymentOptions {
nn, e = n.UnmarshalPolymorphicJSON(n.JsonData)
if e != nil {
return e
}
if nn != nil {
m.PaymentOptions[i] = nn.(PaymentOption)
} else {
m.PaymentOptions[i] = nil
}
}
m.PaymentGateway = model.PaymentGateway
m.BillingAddress = model.BillingAddress
m.TimePlanUpgrade = model.TimePlanUpgrade
m.TimePersonalToCorporateConv = model.TimePersonalToCorporateConv
m.SubscriptionPlanNumber = model.SubscriptionPlanNumber
return
}
// SubscriptionPlanTypeEnum Enum with underlying type: string
type SubscriptionPlanTypeEnum string
// Set of constants representing the allowable values for SubscriptionPlanTypeEnum
const (
SubscriptionPlanTypeFreeTier SubscriptionPlanTypeEnum = "FREE_TIER"
SubscriptionPlanTypePayg SubscriptionPlanTypeEnum = "PAYG"
)
var mappingSubscriptionPlanTypeEnum = map[string]SubscriptionPlanTypeEnum{
"FREE_TIER": SubscriptionPlanTypeFreeTier,
"PAYG": SubscriptionPlanTypePayg,
}
var mappingSubscriptionPlanTypeEnumLowerCase = map[string]SubscriptionPlanTypeEnum{
"free_tier": SubscriptionPlanTypeFreeTier,
"payg": SubscriptionPlanTypePayg,
}
// GetSubscriptionPlanTypeEnumValues Enumerates the set of values for SubscriptionPlanTypeEnum
func GetSubscriptionPlanTypeEnumValues() []SubscriptionPlanTypeEnum {
values := make([]SubscriptionPlanTypeEnum, 0)
for _, v := range mappingSubscriptionPlanTypeEnum {
values = append(values, v)
}
return values
}
// GetSubscriptionPlanTypeEnumStringValues Enumerates the set of values in String for SubscriptionPlanTypeEnum
func GetSubscriptionPlanTypeEnumStringValues() []string {
return []string{
"FREE_TIER",
"PAYG",
}
}
// GetMappingSubscriptionPlanTypeEnum performs case Insensitive comparison on enum value and return the desired enum
func GetMappingSubscriptionPlanTypeEnum(val string) (SubscriptionPlanTypeEnum, bool) {
enum, ok := mappingSubscriptionPlanTypeEnumLowerCase[strings.ToLower(val)]
return enum, ok
}
// SubscriptionUpgradeStateEnum Enum with underlying type: string
type SubscriptionUpgradeStateEnum string
// Set of constants representing the allowable values for SubscriptionUpgradeStateEnum
const (
SubscriptionUpgradeStatePromo SubscriptionUpgradeStateEnum = "PROMO"
SubscriptionUpgradeStateSubmitted SubscriptionUpgradeStateEnum = "SUBMITTED"
SubscriptionUpgradeStateError SubscriptionUpgradeStateEnum = "ERROR"
SubscriptionUpgradeStateUpgraded SubscriptionUpgradeStateEnum = "UPGRADED"
)
var mappingSubscriptionUpgradeStateEnum = map[string]SubscriptionUpgradeStateEnum{
"PROMO": SubscriptionUpgradeStatePromo,
"SUBMITTED": SubscriptionUpgradeStateSubmitted,
"ERROR": SubscriptionUpgradeStateError,
"UPGRADED": SubscriptionUpgradeStateUpgraded,
}
var mappingSubscriptionUpgradeStateEnumLowerCase = map[string]SubscriptionUpgradeStateEnum{
"promo": SubscriptionUpgradeStatePromo,
"submitted": SubscriptionUpgradeStateSubmitted,
"error": SubscriptionUpgradeStateError,
"upgraded": SubscriptionUpgradeStateUpgraded,
}
// GetSubscriptionUpgradeStateEnumValues Enumerates the set of values for SubscriptionUpgradeStateEnum
func GetSubscriptionUpgradeStateEnumValues() []SubscriptionUpgradeStateEnum {
values := make([]SubscriptionUpgradeStateEnum, 0)
for _, v := range mappingSubscriptionUpgradeStateEnum {
values = append(values, v)
}
return values
}
// GetSubscriptionUpgradeStateEnumStringValues Enumerates the set of values in String for SubscriptionUpgradeStateEnum
func GetSubscriptionUpgradeStateEnumStringValues() []string {
return []string{
"PROMO",
"SUBMITTED",
"ERROR",
"UPGRADED",
}
}
// GetMappingSubscriptionUpgradeStateEnum performs case Insensitive comparison on enum value and return the desired enum
func GetMappingSubscriptionUpgradeStateEnum(val string) (SubscriptionUpgradeStateEnum, bool) {
enum, ok := mappingSubscriptionUpgradeStateEnumLowerCase[strings.ToLower(val)]
return enum, ok
}
// SubscriptionUpgradeStateDetailsEnum Enum with underlying type: string
type SubscriptionUpgradeStateDetailsEnum string
// Set of constants representing the allowable values for SubscriptionUpgradeStateDetailsEnum
const (
SubscriptionUpgradeStateDetailsTaxError SubscriptionUpgradeStateDetailsEnum = "TAX_ERROR"
SubscriptionUpgradeStateDetailsUpgradeError SubscriptionUpgradeStateDetailsEnum = "UPGRADE_ERROR"
)
var mappingSubscriptionUpgradeStateDetailsEnum = map[string]SubscriptionUpgradeStateDetailsEnum{
"TAX_ERROR": SubscriptionUpgradeStateDetailsTaxError,
"UPGRADE_ERROR": SubscriptionUpgradeStateDetailsUpgradeError,
}
var mappingSubscriptionUpgradeStateDetailsEnumLowerCase = map[string]SubscriptionUpgradeStateDetailsEnum{
"tax_error": SubscriptionUpgradeStateDetailsTaxError,
"upgrade_error": SubscriptionUpgradeStateDetailsUpgradeError,
}
// GetSubscriptionUpgradeStateDetailsEnumValues Enumerates the set of values for SubscriptionUpgradeStateDetailsEnum
func GetSubscriptionUpgradeStateDetailsEnumValues() []SubscriptionUpgradeStateDetailsEnum {
values := make([]SubscriptionUpgradeStateDetailsEnum, 0)
for _, v := range mappingSubscriptionUpgradeStateDetailsEnum {
values = append(values, v)
}
return values
}
// GetSubscriptionUpgradeStateDetailsEnumStringValues Enumerates the set of values in String for SubscriptionUpgradeStateDetailsEnum
func GetSubscriptionUpgradeStateDetailsEnumStringValues() []string {
return []string{
"TAX_ERROR",
"UPGRADE_ERROR",
}
}
// GetMappingSubscriptionUpgradeStateDetailsEnum performs case Insensitive comparison on enum value and return the desired enum
func GetMappingSubscriptionUpgradeStateDetailsEnum(val string) (SubscriptionUpgradeStateDetailsEnum, bool) {
enum, ok := mappingSubscriptionUpgradeStateDetailsEnumLowerCase[strings.ToLower(val)]
return enum, ok
}
// SubscriptionAccountTypeEnum Enum with underlying type: string
type SubscriptionAccountTypeEnum string
// Set of constants representing the allowable values for SubscriptionAccountTypeEnum
const (
SubscriptionAccountTypePersonal SubscriptionAccountTypeEnum = "PERSONAL"
SubscriptionAccountTypeCorporate SubscriptionAccountTypeEnum = "CORPORATE"
SubscriptionAccountTypeCorporateSubmitted SubscriptionAccountTypeEnum = "CORPORATE_SUBMITTED"
)
var mappingSubscriptionAccountTypeEnum = map[string]SubscriptionAccountTypeEnum{
"PERSONAL": SubscriptionAccountTypePersonal,
"CORPORATE": SubscriptionAccountTypeCorporate,
"CORPORATE_SUBMITTED": SubscriptionAccountTypeCorporateSubmitted,
}
var mappingSubscriptionAccountTypeEnumLowerCase = map[string]SubscriptionAccountTypeEnum{
"personal": SubscriptionAccountTypePersonal,
"corporate": SubscriptionAccountTypeCorporate,
"corporate_submitted": SubscriptionAccountTypeCorporateSubmitted,
}
// GetSubscriptionAccountTypeEnumValues Enumerates the set of values for SubscriptionAccountTypeEnum
func GetSubscriptionAccountTypeEnumValues() []SubscriptionAccountTypeEnum {
values := make([]SubscriptionAccountTypeEnum, 0)
for _, v := range mappingSubscriptionAccountTypeEnum {
values = append(values, v)
}
return values
}
// GetSubscriptionAccountTypeEnumStringValues Enumerates the set of values in String for SubscriptionAccountTypeEnum
func GetSubscriptionAccountTypeEnumStringValues() []string {
return []string{
"PERSONAL",
"CORPORATE",
"CORPORATE_SUBMITTED",
}
}
// GetMappingSubscriptionAccountTypeEnum performs case Insensitive comparison on enum value and return the desired enum
func GetMappingSubscriptionAccountTypeEnum(val string) (SubscriptionAccountTypeEnum, bool) {
enum, ok := mappingSubscriptionAccountTypeEnumLowerCase[strings.ToLower(val)]
return enum, ok
}