billabear 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +509 -364
  3. data/billabear.gemspec +4 -4
  4. data/docs/Address.md +1 -1
  5. data/docs/BillingAdmin.md +1 -1
  6. data/docs/CheckoutApi.md +6 -6
  7. data/docs/CheckoutBody.md +1 -1
  8. data/docs/CheckoutItems.md +1 -1
  9. data/docs/CheckoutSubscriptions.md +1 -1
  10. data/docs/Cost.md +8 -0
  11. data/docs/Customer.md +3 -1
  12. data/docs/CustomerIdUasgelimitBody.md +8 -0
  13. data/docs/CustomersApi.md +319 -101
  14. data/docs/Error.md +1 -1
  15. data/docs/Event.md +11 -0
  16. data/docs/Feature.md +1 -1
  17. data/docs/FrontendToken.md +1 -1
  18. data/docs/InlineResponse200.md +1 -1
  19. data/docs/InlineResponse2001.md +3 -4
  20. data/docs/InlineResponse20010.md +2 -2
  21. data/docs/InlineResponse20011.md +4 -2
  22. data/docs/InlineResponse20012.md +4 -3
  23. data/docs/InlineResponse20013.md +7 -0
  24. data/docs/InlineResponse20014.md +8 -0
  25. data/docs/InlineResponse2002.md +4 -4
  26. data/docs/InlineResponse2003.md +2 -2
  27. data/docs/InlineResponse2004.md +2 -2
  28. data/docs/InlineResponse2005.md +2 -2
  29. data/docs/InlineResponse2006.md +2 -2
  30. data/docs/InlineResponse2007.md +2 -2
  31. data/docs/InlineResponse2008.md +2 -2
  32. data/docs/InlineResponse2009.md +2 -2
  33. data/docs/{InlineResponse2007Data.md → InlineResponse2009Data.md} +2 -2
  34. data/docs/{InlineResponse2007Receipts.md → InlineResponse2009Receipts.md} +1 -1
  35. data/docs/InlineResponse201.md +1 -1
  36. data/docs/InlineResponse201Lines.md +1 -1
  37. data/docs/InlineResponse400.md +1 -1
  38. data/docs/Invoice.md +1 -1
  39. data/docs/InvoiceLines.md +1 -1
  40. data/docs/InvoicesApi.md +17 -17
  41. data/docs/IssueRefundPayment.md +1 -1
  42. data/docs/Limit.md +1 -1
  43. data/docs/Metric.md +12 -0
  44. data/docs/MetricCost.md +10 -0
  45. data/docs/MetricFilter.md +11 -0
  46. data/docs/PaymentDetails.md +1 -1
  47. data/docs/PaymentDetailsApi.md +48 -52
  48. data/docs/PaymentsApi.md +41 -42
  49. data/docs/Price.md +2 -1
  50. data/docs/PricesApi.md +15 -16
  51. data/docs/Product.md +1 -1
  52. data/docs/ProductTaxType.md +1 -1
  53. data/docs/ProductsApi.md +23 -24
  54. data/docs/ReceiptApi.md +5 -5
  55. data/docs/Refund.md +1 -1
  56. data/docs/RefundsApi.md +17 -17
  57. data/docs/SeatsAddBody.md +1 -1
  58. data/docs/SeatsRemoveBody.md +1 -1
  59. data/docs/Subscription.md +2 -1
  60. data/docs/SubscriptionIdCancelBody.md +1 -1
  61. data/docs/SubscriptionIdExtendBody.md +1 -1
  62. data/docs/SubscriptionIdPlanBody.md +2 -2
  63. data/docs/SubscriptionIdPriceBody.md +1 -1
  64. data/docs/SubscriptionPlan.md +1 -1
  65. data/docs/SubscriptionStartBody.md +2 -1
  66. data/docs/SubscriptionTrialBody.md +1 -1
  67. data/docs/SubscriptionsApi.md +78 -79
  68. data/docs/UsageApi.md +279 -0
  69. data/docs/UsageLimit.md +9 -0
  70. data/docs/VoucherCode.md +1 -1
  71. data/git_push.sh +2 -2
  72. data/lib/{swagger_client → billabear}/api/checkout_api.rb +3 -3
  73. data/lib/{swagger_client → billabear}/api/customers_api.rb +284 -45
  74. data/lib/{swagger_client → billabear}/api/invoices_api.rb +9 -9
  75. data/lib/{swagger_client → billabear}/api/payment_details_api.rb +26 -26
  76. data/lib/{swagger_client → billabear}/api/payments_api.rb +20 -20
  77. data/lib/{swagger_client → billabear}/api/prices_api.rb +11 -11
  78. data/lib/{swagger_client → billabear}/api/products_api.rb +11 -11
  79. data/lib/{swagger_client → billabear}/api/receipt_api.rb +3 -3
  80. data/lib/{swagger_client → billabear}/api/refunds_api.rb +9 -9
  81. data/lib/{swagger_client → billabear}/api/subscriptions_api.rb +29 -29
  82. data/lib/billabear/api/usage_api.rb +314 -0
  83. data/lib/{swagger_client → billabear}/api_client.rb +4 -4
  84. data/lib/{swagger_client → billabear}/api_error.rb +3 -3
  85. data/lib/{swagger_client → billabear}/configuration.rb +3 -3
  86. data/lib/{swagger_client → billabear}/models/address.rb +6 -6
  87. data/lib/{swagger_client → billabear}/models/billing_admin.rb +6 -6
  88. data/lib/{swagger_client → billabear}/models/checkout_body.rb +6 -6
  89. data/lib/{swagger_client → billabear}/models/checkout_items.rb +6 -6
  90. data/lib/{swagger_client → billabear}/models/checkout_subscriptions.rb +6 -6
  91. data/lib/billabear/models/cost.rb +215 -0
  92. data/lib/{swagger_client → billabear}/models/customer.rb +45 -11
  93. data/lib/billabear/models/customer_id_uasgelimit_body.rb +259 -0
  94. data/lib/{swagger_client → billabear}/models/error.rb +6 -6
  95. data/lib/billabear/models/event.rb +262 -0
  96. data/lib/{swagger_client → billabear}/models/feature.rb +6 -6
  97. data/lib/{swagger_client → billabear}/models/frontend_token.rb +6 -6
  98. data/lib/{swagger_client → billabear}/models/inline_response_200.rb +6 -6
  99. data/lib/billabear/models/inline_response_200_1.rb +217 -0
  100. data/lib/{swagger_client → billabear}/models/inline_response_200_10.rb +6 -6
  101. data/lib/{swagger_client/models/inline_response_200_2.rb → billabear/models/inline_response_200_11.rb} +7 -7
  102. data/lib/billabear/models/inline_response_200_12.rb +226 -0
  103. data/lib/{swagger_client/models/inline_response_200_11.rb → billabear/models/inline_response_200_13.rb} +7 -7
  104. data/lib/{swagger_client/models/inline_response_200_12.rb → billabear/models/inline_response_200_14.rb} +7 -7
  105. data/lib/{swagger_client/models/inline_response_200_1.rb → billabear/models/inline_response_200_2.rb} +7 -7
  106. data/lib/{swagger_client → billabear}/models/inline_response_200_3.rb +6 -6
  107. data/lib/{swagger_client → billabear}/models/inline_response_200_4.rb +6 -6
  108. data/lib/{swagger_client → billabear}/models/inline_response_200_5.rb +6 -6
  109. data/lib/{swagger_client → billabear}/models/inline_response_200_6.rb +6 -6
  110. data/lib/{swagger_client → billabear}/models/inline_response_200_7.rb +6 -6
  111. data/lib/{swagger_client → billabear}/models/inline_response_200_8.rb +6 -6
  112. data/lib/{swagger_client → billabear}/models/inline_response_200_9.rb +6 -6
  113. data/lib/{swagger_client/models/inline_response_200_7_data.rb → billabear/models/inline_response_200_9_data.rb} +7 -7
  114. data/lib/{swagger_client/models/inline_response_200_7_receipts.rb → billabear/models/inline_response_200_9_receipts.rb} +7 -7
  115. data/lib/{swagger_client → billabear}/models/inline_response_201.rb +6 -6
  116. data/lib/{swagger_client → billabear}/models/inline_response_201_lines.rb +6 -6
  117. data/lib/{swagger_client → billabear}/models/inline_response_400.rb +6 -6
  118. data/lib/{swagger_client → billabear}/models/invoice.rb +6 -6
  119. data/lib/{swagger_client → billabear}/models/invoice_lines.rb +6 -6
  120. data/lib/{swagger_client → billabear}/models/issue_refund_payment.rb +6 -6
  121. data/lib/{swagger_client → billabear}/models/limit.rb +6 -6
  122. data/lib/billabear/models/metric.rb +288 -0
  123. data/lib/billabear/models/metric_cost.rb +234 -0
  124. data/lib/billabear/models/metric_filter.rb +276 -0
  125. data/lib/{swagger_client → billabear}/models/payment_details.rb +6 -6
  126. data/lib/{swagger_client → billabear}/models/price.rb +20 -11
  127. data/lib/{swagger_client → billabear}/models/product.rb +6 -6
  128. data/lib/{swagger_client → billabear}/models/product_tax_type.rb +6 -6
  129. data/lib/{swagger_client → billabear}/models/refund.rb +6 -6
  130. data/lib/{swagger_client → billabear}/models/seats_add_body.rb +6 -6
  131. data/lib/{swagger_client → billabear}/models/seats_remove_body.rb +6 -6
  132. data/lib/{swagger_client → billabear}/models/subscription.rb +16 -7
  133. data/lib/{swagger_client → billabear}/models/subscription_id_cancel_body.rb +6 -6
  134. data/lib/{swagger_client → billabear}/models/subscription_id_extend_body.rb +6 -6
  135. data/lib/{swagger_client → billabear}/models/subscription_id_plan_body.rb +11 -6
  136. data/lib/{swagger_client → billabear}/models/subscription_id_price_body.rb +6 -6
  137. data/lib/{swagger_client → billabear}/models/subscription_plan.rb +6 -6
  138. data/lib/{swagger_client → billabear}/models/subscription_start_body.rb +20 -10
  139. data/lib/{swagger_client → billabear}/models/subscription_trial_body.rb +6 -6
  140. data/lib/billabear/models/usage_limit.rb +258 -0
  141. data/lib/{swagger_client → billabear}/models/voucher_code.rb +6 -6
  142. data/lib/{swagger_client → billabear}/version.rb +4 -4
  143. data/lib/billabear.rb +105 -0
  144. data/spec/api/checkout_api_spec.rb +5 -5
  145. data/spec/api/customers_api_spec.rb +68 -17
  146. data/spec/api/invoices_api_spec.rb +7 -7
  147. data/spec/api/payment_details_api_spec.rb +10 -10
  148. data/spec/api/payments_api_spec.rb +10 -10
  149. data/spec/api/prices_api_spec.rb +7 -7
  150. data/spec/api/products_api_spec.rb +7 -7
  151. data/spec/api/receipt_api_spec.rb +5 -5
  152. data/spec/api/refunds_api_spec.rb +7 -7
  153. data/spec/api/subscriptions_api_spec.rb +13 -13
  154. data/spec/api/usage_api_spec.rb +96 -0
  155. data/spec/api_client_spec.rb +31 -31
  156. data/spec/configuration_spec.rb +5 -5
  157. data/spec/models/address_spec.rb +5 -5
  158. data/spec/models/billing_admin_spec.rb +5 -5
  159. data/spec/models/checkout_body_spec.rb +5 -5
  160. data/spec/models/checkout_items_spec.rb +5 -5
  161. data/spec/models/checkout_subscriptions_spec.rb +5 -5
  162. data/spec/models/cost_spec.rb +46 -0
  163. data/spec/models/customer_id_uasgelimit_body_spec.rb +50 -0
  164. data/spec/models/customer_spec.rb +21 -5
  165. data/spec/models/error_spec.rb +5 -5
  166. data/spec/models/event_spec.rb +64 -0
  167. data/spec/models/feature_spec.rb +5 -5
  168. data/spec/models/frontend_token_spec.rb +5 -5
  169. data/spec/models/inline_response_200_10_spec.rb +5 -5
  170. data/spec/models/inline_response_200_11_spec.rb +18 -6
  171. data/spec/models/inline_response_200_12_spec.rb +13 -11
  172. data/spec/models/inline_response_200_13_spec.rb +40 -0
  173. data/spec/models/inline_response_200_14_spec.rb +50 -0
  174. data/spec/models/inline_response_200_1_spec.rb +7 -13
  175. data/spec/models/inline_response_200_2_spec.rb +8 -8
  176. data/spec/models/inline_response_200_3_spec.rb +5 -5
  177. data/spec/models/inline_response_200_4_spec.rb +5 -5
  178. data/spec/models/inline_response_200_5_spec.rb +5 -5
  179. data/spec/models/inline_response_200_6_spec.rb +5 -5
  180. data/spec/models/inline_response_200_7_spec.rb +5 -5
  181. data/spec/models/inline_response_200_8_spec.rb +5 -5
  182. data/spec/models/{inline_response_200_7_data_spec.rb → inline_response_200_9_data_spec.rb} +8 -8
  183. data/spec/models/{inline_response_200_7_receipts_spec.rb → inline_response_200_9_receipts_spec.rb} +8 -8
  184. data/spec/models/inline_response_200_9_spec.rb +5 -5
  185. data/spec/models/inline_response_200_spec.rb +5 -5
  186. data/spec/models/inline_response_201_lines_spec.rb +5 -5
  187. data/spec/models/inline_response_201_spec.rb +5 -5
  188. data/spec/models/inline_response_400_spec.rb +5 -5
  189. data/spec/models/invoice_lines_spec.rb +5 -5
  190. data/spec/models/invoice_spec.rb +5 -5
  191. data/spec/models/issue_refund_payment_spec.rb +5 -5
  192. data/spec/models/limit_spec.rb +5 -5
  193. data/spec/models/metric_cost_spec.rb +58 -0
  194. data/spec/models/metric_filter_spec.rb +68 -0
  195. data/spec/models/metric_spec.rb +74 -0
  196. data/spec/models/payment_details_spec.rb +5 -5
  197. data/spec/models/price_spec.rb +11 -5
  198. data/spec/models/product_spec.rb +5 -5
  199. data/spec/models/product_tax_type_spec.rb +5 -5
  200. data/spec/models/refund_spec.rb +5 -5
  201. data/spec/models/seats_add_body_spec.rb +5 -5
  202. data/spec/models/seats_remove_body_spec.rb +5 -5
  203. data/spec/models/subscription_id_cancel_body_spec.rb +5 -5
  204. data/spec/models/subscription_id_extend_body_spec.rb +5 -5
  205. data/spec/models/subscription_id_plan_body_spec.rb +5 -5
  206. data/spec/models/subscription_id_price_body_spec.rb +5 -5
  207. data/spec/models/subscription_plan_spec.rb +5 -5
  208. data/spec/models/subscription_spec.rb +11 -5
  209. data/spec/models/subscription_start_body_spec.rb +11 -5
  210. data/spec/models/subscription_trial_body_spec.rb +5 -5
  211. data/spec/models/usage_limit_spec.rb +56 -0
  212. data/spec/models/voucher_code_spec.rb +5 -5
  213. data/spec/spec_helper.rb +3 -3
  214. metadata +110 -70
  215. data/lib/swagger_client.rb +0 -95
@@ -3,15 +3,15 @@
3
3
 
4
4
  #The REST API provided by BillaBear
5
5
 
6
- OpenAPI spec version: 1.0.0
6
+ OpenAPI spec version: 1.1.0
7
7
  Contact: support@billabear.com
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 3.0.56
9
+ Swagger Codegen version: 3.0.66
10
10
  =end
11
11
 
12
12
  require 'date'
13
13
 
14
- module SwaggerClient
14
+ module Billabear
15
15
  class Limit
16
16
  attr_accessor :feature
17
17
 
@@ -43,13 +43,13 @@ module SwaggerClient
43
43
  # @param [Hash] attributes Model attributes in the form of hash
44
44
  def initialize(attributes = {})
45
45
  if (!attributes.is_a?(Hash))
46
- fail ArgumentError, "The input argument (attributes) must be a hash in `SwaggerClient::Limit` initialize method"
46
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Billabear::Limit` initialize method"
47
47
  end
48
48
 
49
49
  # check to see if the attribute exists and convert string to symbol for hash key
50
50
  attributes = attributes.each_with_object({}) { |(k, v), h|
51
51
  if (!self.class.attribute_map.key?(k.to_sym))
52
- fail ArgumentError, "`#{k}` is not a valid attribute in `SwaggerClient::Limit`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
52
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Billabear::Limit`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
53
53
  end
54
54
  h[k.to_sym] = v
55
55
  }
@@ -163,7 +163,7 @@ module SwaggerClient
163
163
  end
164
164
  end
165
165
  else # model
166
- SwaggerClient.const_get(type).build_from_hash(value)
166
+ Billabear.const_get(type).build_from_hash(value)
167
167
  end
168
168
  end
169
169
 
@@ -0,0 +1,288 @@
1
+ =begin
2
+ #BillaBear
3
+
4
+ #The REST API provided by BillaBear
5
+
6
+ OpenAPI spec version: 1.1.0
7
+ Contact: support@billabear.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.66
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module Billabear
15
+ class Metric
16
+ attr_accessor :id
17
+
18
+ attr_accessor :name
19
+
20
+ attr_accessor :code
21
+
22
+ attr_accessor :aggregation_method
23
+
24
+ attr_accessor :aggregation_property
25
+
26
+ attr_accessor :filters
27
+
28
+ class EnumAttributeValidator
29
+ attr_reader :datatype
30
+ attr_reader :allowable_values
31
+
32
+ def initialize(datatype, allowable_values)
33
+ @allowable_values = allowable_values.map do |value|
34
+ case datatype.to_s
35
+ when /Integer/i
36
+ value.to_i
37
+ when /Float/i
38
+ value.to_f
39
+ else
40
+ value
41
+ end
42
+ end
43
+ end
44
+
45
+ def valid?(value)
46
+ !value || allowable_values.include?(value)
47
+ end
48
+ end
49
+
50
+ # Attribute mapping from ruby-style variable name to JSON key.
51
+ def self.attribute_map
52
+ {
53
+ :'id' => :'id',
54
+ :'name' => :'name',
55
+ :'code' => :'code',
56
+ :'aggregation_method' => :'aggregation_method',
57
+ :'aggregation_property' => :'aggregation_property',
58
+ :'filters' => :'filters'
59
+ }
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.openapi_types
64
+ {
65
+ :'id' => :'Object',
66
+ :'name' => :'Object',
67
+ :'code' => :'Object',
68
+ :'aggregation_method' => :'Object',
69
+ :'aggregation_property' => :'Object',
70
+ :'filters' => :'Object'
71
+ }
72
+ end
73
+
74
+ # List of attributes with nullable: true
75
+ def self.openapi_nullable
76
+ Set.new([
77
+ :'aggregation_property',
78
+ ])
79
+ end
80
+
81
+ # Initializes the object
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ def initialize(attributes = {})
84
+ if (!attributes.is_a?(Hash))
85
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Billabear::Metric` initialize method"
86
+ end
87
+
88
+ # check to see if the attribute exists and convert string to symbol for hash key
89
+ attributes = attributes.each_with_object({}) { |(k, v), h|
90
+ if (!self.class.attribute_map.key?(k.to_sym))
91
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Billabear::Metric`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
92
+ end
93
+ h[k.to_sym] = v
94
+ }
95
+
96
+ if attributes.key?(:'id')
97
+ self.id = attributes[:'id']
98
+ end
99
+
100
+ if attributes.key?(:'name')
101
+ self.name = attributes[:'name']
102
+ end
103
+
104
+ if attributes.key?(:'code')
105
+ self.code = attributes[:'code']
106
+ end
107
+
108
+ if attributes.key?(:'aggregation_method')
109
+ self.aggregation_method = attributes[:'aggregation_method']
110
+ end
111
+
112
+ if attributes.key?(:'aggregation_property')
113
+ self.aggregation_property = attributes[:'aggregation_property']
114
+ end
115
+
116
+ if attributes.key?(:'filters')
117
+ if (value = attributes[:'filters']).is_a?(Array)
118
+ self.filters = value
119
+ end
120
+ end
121
+ end
122
+
123
+ # Show invalid properties with the reasons. Usually used together with valid?
124
+ # @return Array for valid properties with the reasons
125
+ def list_invalid_properties
126
+ invalid_properties = Array.new
127
+ invalid_properties
128
+ end
129
+
130
+ # Check to see if the all the properties in the model are valid
131
+ # @return true if the model is valid
132
+ def valid?
133
+ aggregation_method_validator = EnumAttributeValidator.new('Object', ['count', 'sum', 'latest', 'unique_count', 'max'])
134
+ return false unless aggregation_method_validator.valid?(@aggregation_method)
135
+ true
136
+ end
137
+
138
+ # Custom attribute writer method checking allowed values (enum).
139
+ # @param [Object] aggregation_method Object to be assigned
140
+ def aggregation_method=(aggregation_method)
141
+ validator = EnumAttributeValidator.new('Object', ['count', 'sum', 'latest', 'unique_count', 'max'])
142
+ unless validator.valid?(aggregation_method)
143
+ fail ArgumentError, "invalid value for \"aggregation_method\", must be one of #{validator.allowable_values}."
144
+ end
145
+ @aggregation_method = aggregation_method
146
+ end
147
+
148
+ # Checks equality by comparing each attribute.
149
+ # @param [Object] Object to be compared
150
+ def ==(o)
151
+ return true if self.equal?(o)
152
+ self.class == o.class &&
153
+ id == o.id &&
154
+ name == o.name &&
155
+ code == o.code &&
156
+ aggregation_method == o.aggregation_method &&
157
+ aggregation_property == o.aggregation_property &&
158
+ filters == o.filters
159
+ end
160
+
161
+ # @see the `==` method
162
+ # @param [Object] Object to be compared
163
+ def eql?(o)
164
+ self == o
165
+ end
166
+
167
+ # Calculates hash code according to all attributes.
168
+ # @return [Integer] Hash code
169
+ def hash
170
+ [id, name, code, aggregation_method, aggregation_property, filters].hash
171
+ end
172
+
173
+ # Builds the object from hash
174
+ # @param [Hash] attributes Model attributes in the form of hash
175
+ # @return [Object] Returns the model itself
176
+ def self.build_from_hash(attributes)
177
+ new.build_from_hash(attributes)
178
+ end
179
+
180
+ # Builds the object from hash
181
+ # @param [Hash] attributes Model attributes in the form of hash
182
+ # @return [Object] Returns the model itself
183
+ def build_from_hash(attributes)
184
+ return nil unless attributes.is_a?(Hash)
185
+ self.class.openapi_types.each_pair do |key, type|
186
+ if type =~ /\AArray<(.*)>/i
187
+ # check to ensure the input is an array given that the attribute
188
+ # is documented as an array but the input is not
189
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
190
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
191
+ end
192
+ elsif !attributes[self.class.attribute_map[key]].nil?
193
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
194
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
195
+ self.send("#{key}=", nil)
196
+ end
197
+ end
198
+
199
+ self
200
+ end
201
+
202
+ # Deserializes the data based on type
203
+ # @param string type Data type
204
+ # @param string value Value to be deserialized
205
+ # @return [Object] Deserialized data
206
+ def _deserialize(type, value)
207
+ case type.to_sym
208
+ when :DateTime
209
+ DateTime.parse(value)
210
+ when :Date
211
+ Date.parse(value)
212
+ when :String
213
+ value.to_s
214
+ when :Integer
215
+ value.to_i
216
+ when :Float
217
+ value.to_f
218
+ when :Boolean
219
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
220
+ true
221
+ else
222
+ false
223
+ end
224
+ when :Object
225
+ # generic object (usually a Hash), return directly
226
+ value
227
+ when /\AArray<(?<inner_type>.+)>\z/
228
+ inner_type = Regexp.last_match[:inner_type]
229
+ value.map { |v| _deserialize(inner_type, v) }
230
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
231
+ k_type = Regexp.last_match[:k_type]
232
+ v_type = Regexp.last_match[:v_type]
233
+ {}.tap do |hash|
234
+ value.each do |k, v|
235
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
236
+ end
237
+ end
238
+ else # model
239
+ Billabear.const_get(type).build_from_hash(value)
240
+ end
241
+ end
242
+
243
+ # Returns the string representation of the object
244
+ # @return [String] String presentation of the object
245
+ def to_s
246
+ to_hash.to_s
247
+ end
248
+
249
+ # to_body is an alias to to_hash (backward compatibility)
250
+ # @return [Hash] Returns the object in the form of hash
251
+ def to_body
252
+ to_hash
253
+ end
254
+
255
+ # Returns the object in the form of hash
256
+ # @return [Hash] Returns the object in the form of hash
257
+ def to_hash
258
+ hash = {}
259
+ self.class.attribute_map.each_pair do |attr, param|
260
+ value = self.send(attr)
261
+ if value.nil?
262
+ is_nullable = self.class.openapi_nullable.include?(attr)
263
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
264
+ end
265
+
266
+ hash[param] = _to_hash(value)
267
+ end
268
+ hash
269
+ end
270
+
271
+ # Outputs non-array value in the form of hash
272
+ # For object, use to_hash. Otherwise, just return the value
273
+ # @param [Object] value Any valid value
274
+ # @return [Hash] Returns the value in the form of hash
275
+ def _to_hash(value)
276
+ if value.is_a?(Array)
277
+ value.compact.map { |v| _to_hash(v) }
278
+ elsif value.is_a?(Hash)
279
+ {}.tap do |hash|
280
+ value.each { |k, v| hash[k] = _to_hash(v) }
281
+ end
282
+ elsif value.respond_to? :to_hash
283
+ value.to_hash
284
+ else
285
+ value
286
+ end
287
+ end end
288
+ end
@@ -0,0 +1,234 @@
1
+ =begin
2
+ #BillaBear
3
+
4
+ #The REST API provided by BillaBear
5
+
6
+ OpenAPI spec version: 1.1.0
7
+ Contact: support@billabear.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.66
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module Billabear
15
+ class MetricCost
16
+ # The name of the metric that the cost is for
17
+ attr_accessor :name
18
+
19
+ attr_accessor :amount
20
+
21
+ attr_accessor :currency
22
+
23
+ attr_accessor :usage
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'name' => :'name',
29
+ :'amount' => :'amount',
30
+ :'currency' => :'currency',
31
+ :'usage' => :'usage'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'name' => :'Object',
39
+ :'amount' => :'Object',
40
+ :'currency' => :'Object',
41
+ :'usage' => :'Object'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Billabear::MetricCost` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Billabear::MetricCost`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'name')
67
+ self.name = attributes[:'name']
68
+ end
69
+
70
+ if attributes.key?(:'amount')
71
+ self.amount = attributes[:'amount']
72
+ end
73
+
74
+ if attributes.key?(:'currency')
75
+ self.currency = attributes[:'currency']
76
+ end
77
+
78
+ if attributes.key?(:'usage')
79
+ self.usage = attributes[:'usage']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ invalid_properties = Array.new
87
+ invalid_properties
88
+ end
89
+
90
+ # Check to see if the all the properties in the model are valid
91
+ # @return true if the model is valid
92
+ def valid?
93
+ true
94
+ end
95
+
96
+ # Checks equality by comparing each attribute.
97
+ # @param [Object] Object to be compared
98
+ def ==(o)
99
+ return true if self.equal?(o)
100
+ self.class == o.class &&
101
+ name == o.name &&
102
+ amount == o.amount &&
103
+ currency == o.currency &&
104
+ usage == o.usage
105
+ end
106
+
107
+ # @see the `==` method
108
+ # @param [Object] Object to be compared
109
+ def eql?(o)
110
+ self == o
111
+ end
112
+
113
+ # Calculates hash code according to all attributes.
114
+ # @return [Integer] Hash code
115
+ def hash
116
+ [name, amount, currency, usage].hash
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def self.build_from_hash(attributes)
123
+ new.build_from_hash(attributes)
124
+ end
125
+
126
+ # Builds the object from hash
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ # @return [Object] Returns the model itself
129
+ def build_from_hash(attributes)
130
+ return nil unless attributes.is_a?(Hash)
131
+ self.class.openapi_types.each_pair do |key, type|
132
+ if type =~ /\AArray<(.*)>/i
133
+ # check to ensure the input is an array given that the attribute
134
+ # is documented as an array but the input is not
135
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
136
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
137
+ end
138
+ elsif !attributes[self.class.attribute_map[key]].nil?
139
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
140
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
141
+ self.send("#{key}=", nil)
142
+ end
143
+ end
144
+
145
+ self
146
+ end
147
+
148
+ # Deserializes the data based on type
149
+ # @param string type Data type
150
+ # @param string value Value to be deserialized
151
+ # @return [Object] Deserialized data
152
+ def _deserialize(type, value)
153
+ case type.to_sym
154
+ when :DateTime
155
+ DateTime.parse(value)
156
+ when :Date
157
+ Date.parse(value)
158
+ when :String
159
+ value.to_s
160
+ when :Integer
161
+ value.to_i
162
+ when :Float
163
+ value.to_f
164
+ when :Boolean
165
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
166
+ true
167
+ else
168
+ false
169
+ end
170
+ when :Object
171
+ # generic object (usually a Hash), return directly
172
+ value
173
+ when /\AArray<(?<inner_type>.+)>\z/
174
+ inner_type = Regexp.last_match[:inner_type]
175
+ value.map { |v| _deserialize(inner_type, v) }
176
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
177
+ k_type = Regexp.last_match[:k_type]
178
+ v_type = Regexp.last_match[:v_type]
179
+ {}.tap do |hash|
180
+ value.each do |k, v|
181
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
182
+ end
183
+ end
184
+ else # model
185
+ Billabear.const_get(type).build_from_hash(value)
186
+ end
187
+ end
188
+
189
+ # Returns the string representation of the object
190
+ # @return [String] String presentation of the object
191
+ def to_s
192
+ to_hash.to_s
193
+ end
194
+
195
+ # to_body is an alias to to_hash (backward compatibility)
196
+ # @return [Hash] Returns the object in the form of hash
197
+ def to_body
198
+ to_hash
199
+ end
200
+
201
+ # Returns the object in the form of hash
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_hash
204
+ hash = {}
205
+ self.class.attribute_map.each_pair do |attr, param|
206
+ value = self.send(attr)
207
+ if value.nil?
208
+ is_nullable = self.class.openapi_nullable.include?(attr)
209
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
210
+ end
211
+
212
+ hash[param] = _to_hash(value)
213
+ end
214
+ hash
215
+ end
216
+
217
+ # Outputs non-array value in the form of hash
218
+ # For object, use to_hash. Otherwise, just return the value
219
+ # @param [Object] value Any valid value
220
+ # @return [Hash] Returns the value in the form of hash
221
+ def _to_hash(value)
222
+ if value.is_a?(Array)
223
+ value.compact.map { |v| _to_hash(v) }
224
+ elsif value.is_a?(Hash)
225
+ {}.tap do |hash|
226
+ value.each { |k, v| hash[k] = _to_hash(v) }
227
+ end
228
+ elsif value.respond_to? :to_hash
229
+ value.to_hash
230
+ else
231
+ value
232
+ end
233
+ end end
234
+ end