growwer 2.0.0 → 2.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 (201) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +57 -4
  3. data/docs/AccountApi.md +1 -1
  4. data/docs/AdvanceTestOrderRequest.md +18 -0
  5. data/docs/BalanceLowEventData.md +20 -0
  6. data/docs/BalanceLowEventDataWallet.md +20 -0
  7. data/docs/CatalogueApi.md +2 -2
  8. data/docs/CreateWebhookRequest.md +24 -0
  9. data/docs/GetMe200Response.md +3 -1
  10. data/docs/ListWebhookDeliveries200Response.md +20 -0
  11. data/docs/ListWebhooks200Response.md +20 -0
  12. data/docs/OrderEventData.md +18 -0
  13. data/docs/TestHelpersApi.md +222 -0
  14. data/docs/TopUpTestWallet200Response.md +20 -0
  15. data/docs/TopUpTestWalletRequest.md +18 -0
  16. data/docs/UpdateWebhookRequest.md +26 -0
  17. data/docs/Webhook.md +38 -0
  18. data/docs/WebhookDelivery.md +32 -0
  19. data/docs/WebhookDeliveryAttempt.md +26 -0
  20. data/docs/WebhookEvent.md +28 -0
  21. data/docs/WebhookEventData.md +51 -0
  22. data/docs/WebhookEventType.md +15 -0
  23. data/docs/WebhookTestEventData.md +18 -0
  24. data/docs/WebhookWithSecret.md +40 -0
  25. data/docs/WebhooksApi.md +662 -0
  26. data/growwer.gemspec +1 -1
  27. data/lib/growwer/api/account_api.rb +3 -3
  28. data/lib/growwer/api/buyer_orders_api.rb +1 -1
  29. data/lib/growwer/api/buyer_wallet_api.rb +1 -1
  30. data/lib/growwer/api/catalogue_api.rb +5 -5
  31. data/lib/growwer/api/files_api.rb +1 -1
  32. data/lib/growwer/api/managed_services_api.rb +1 -1
  33. data/lib/growwer/api/projects_api.rb +1 -1
  34. data/lib/growwer/api/saved_filters_api.rb +1 -1
  35. data/lib/growwer/api/seller_account_api.rb +1 -1
  36. data/lib/growwer/api/seller_medias_api.rb +1 -1
  37. data/lib/growwer/api/seller_orders_api.rb +1 -1
  38. data/lib/growwer/api/seller_wallet_api.rb +1 -1
  39. data/lib/growwer/api/test_helpers_api.rb +254 -0
  40. data/lib/growwer/api/webhooks_api.rb +707 -0
  41. data/lib/growwer/api_client.rb +2 -2
  42. data/lib/growwer/api_error.rb +1 -1
  43. data/lib/growwer/api_model_base.rb +1 -1
  44. data/lib/growwer/configuration.rb +1 -1
  45. data/lib/growwer/models/advance_test_order_request.rb +189 -0
  46. data/lib/growwer/models/balance.rb +1 -1
  47. data/lib/growwer/models/balance_low_event_data.rb +192 -0
  48. data/lib/growwer/models/balance_low_event_data_wallet.rb +192 -0
  49. data/lib/growwer/models/catalogue_media.rb +1 -1
  50. data/lib/growwer/models/catalogue_media_flash_offer.rb +1 -1
  51. data/lib/growwer/models/catalogue_media_metrics.rb +1 -1
  52. data/lib/growwer/models/catalogue_offer.rb +1 -1
  53. data/lib/growwer/models/catalogue_offer_or_null.rb +1 -1
  54. data/lib/growwer/models/catalogue_post_offer.rb +1 -1
  55. data/lib/growwer/models/catalogue_post_offer_all_of_extras.rb +1 -1
  56. data/lib/growwer/models/catalogue_post_offer_all_of_extras_sensitive_topic.rb +1 -1
  57. data/lib/growwer/models/code_name.rb +1 -1
  58. data/lib/growwer/models/count_saved_filter_medias200_response.rb +1 -1
  59. data/lib/growwer/models/create_project_request.rb +1 -1
  60. data/lib/growwer/models/create_saved_filter_request.rb +1 -1
  61. data/lib/growwer/models/create_seller_media_request.rb +1 -1
  62. data/lib/growwer/models/create_seller_media_request_post_offer.rb +1 -1
  63. data/lib/growwer/models/create_webhook_request.rb +248 -0
  64. data/lib/growwer/models/error.rb +1 -1
  65. data/lib/growwer/models/get_buyer_wallet200_response.rb +1 -1
  66. data/lib/growwer/models/get_me200_response.rb +57 -20
  67. data/lib/growwer/models/get_me200_response_buyer.rb +1 -1
  68. data/lib/growwer/models/get_me200_response_catalogue.rb +1 -1
  69. data/lib/growwer/models/get_me200_response_managed_service.rb +1 -1
  70. data/lib/growwer/models/get_me200_response_seller.rb +2 -1
  71. data/lib/growwer/models/get_seller_wallet200_response.rb +1 -1
  72. data/lib/growwer/models/get_vocabulary200_response.rb +1 -1
  73. data/lib/growwer/models/get_vocabulary200_response_topics_inner.rb +1 -1
  74. data/lib/growwer/models/invoice.rb +1 -1
  75. data/lib/growwer/models/link_addition_order_briefing.rb +1 -1
  76. data/lib/growwer/models/link_addition_order_briefing_request.rb +1 -1
  77. data/lib/growwer/models/list_buyer_transactions200_response.rb +1 -1
  78. data/lib/growwer/models/list_flash_offers200_response.rb +1 -1
  79. data/lib/growwer/models/list_invoices200_response.rb +1 -1
  80. data/lib/growwer/models/list_managed_service_campaigns200_response.rb +1 -1
  81. data/lib/growwer/models/list_managed_service_proposals200_response.rb +1 -1
  82. data/lib/growwer/models/list_orders200_response.rb +1 -1
  83. data/lib/growwer/models/list_projects200_response.rb +1 -1
  84. data/lib/growwer/models/list_saved_filters200_response.rb +1 -1
  85. data/lib/growwer/models/list_seller_medias200_response.rb +1 -1
  86. data/lib/growwer/models/list_seller_orders200_response.rb +1 -1
  87. data/lib/growwer/models/list_seller_transactions200_response.rb +1 -1
  88. data/lib/growwer/models/list_webhook_deliveries200_response.rb +192 -0
  89. data/lib/growwer/models/list_webhooks200_response.rb +192 -0
  90. data/lib/growwer/models/list_withdrawals200_response.rb +1 -1
  91. data/lib/growwer/models/managed_service_campaign.rb +1 -1
  92. data/lib/growwer/models/managed_service_campaign_project.rb +1 -1
  93. data/lib/growwer/models/managed_service_campaign_proposal_counts.rb +1 -1
  94. data/lib/growwer/models/managed_service_campaign_strategy.rb +1 -1
  95. data/lib/growwer/models/managed_service_proposal.rb +1 -1
  96. data/lib/growwer/models/managed_service_proposal_briefing.rb +1 -1
  97. data/lib/growwer/models/managed_service_proposal_briefing_links_inner.rb +1 -1
  98. data/lib/growwer/models/managed_service_proposal_media.rb +1 -1
  99. data/lib/growwer/models/managed_service_proposal_review.rb +1 -1
  100. data/lib/growwer/models/managed_service_proposal_review_request.rb +1 -1
  101. data/lib/growwer/models/managed_service_proposal_review_request_reviews_inner.rb +1 -1
  102. data/lib/growwer/models/managed_service_proposals_estimate.rb +1 -1
  103. data/lib/growwer/models/managed_service_proposals_estimate_request.rb +1 -1
  104. data/lib/growwer/models/managed_service_request.rb +1 -1
  105. data/lib/growwer/models/managed_service_request_sent.rb +1 -1
  106. data/lib/growwer/models/money.rb +1 -1
  107. data/lib/growwer/models/money_or_null.rb +1 -1
  108. data/lib/growwer/models/order.rb +1 -1
  109. data/lib/growwer/models/order_action_reason.rb +1 -1
  110. data/lib/growwer/models/order_briefing.rb +1 -1
  111. data/lib/growwer/models/order_channel.rb +1 -1
  112. data/lib/growwer/models/order_create_request.rb +1 -1
  113. data/lib/growwer/models/order_delivery.rb +1 -1
  114. data/lib/growwer/models/order_draft.rb +1 -1
  115. data/lib/growwer/models/order_estimate.rb +1 -1
  116. data/lib/growwer/models/order_estimate_request.rb +1 -1
  117. data/lib/growwer/models/order_estimate_request_briefing.rb +1 -1
  118. data/lib/growwer/models/order_event_data.rb +165 -0
  119. data/lib/growwer/models/order_link.rb +1 -1
  120. data/lib/growwer/models/order_link_request.rb +1 -1
  121. data/lib/growwer/models/order_media.rb +1 -1
  122. data/lib/growwer/models/order_project.rb +1 -1
  123. data/lib/growwer/models/order_state_history_inner.rb +1 -1
  124. data/lib/growwer/models/order_state_history_inner_reason.rb +1 -1
  125. data/lib/growwer/models/post_order_briefing.rb +1 -1
  126. data/lib/growwer/models/post_order_briefing_request.rb +1 -1
  127. data/lib/growwer/models/project.rb +1 -1
  128. data/lib/growwer/models/project_catalogue_media.rb +1 -1
  129. data/lib/growwer/models/project_catalogue_media_all_of_project.rb +1 -1
  130. data/lib/growwer/models/project_catalogue_media_all_of_project_ai_keywords.rb +1 -1
  131. data/lib/growwer/models/put_seller_holiday200_response.rb +1 -1
  132. data/lib/growwer/models/put_seller_holiday_request.rb +1 -1
  133. data/lib/growwer/models/request_medias201_response.rb +1 -1
  134. data/lib/growwer/models/request_medias_request.rb +1 -1
  135. data/lib/growwer/models/saved_filter.rb +1 -1
  136. data/lib/growwer/models/saved_filter_notifications.rb +1 -1
  137. data/lib/growwer/models/seller_fees.rb +1 -1
  138. data/lib/growwer/models/seller_fees_or_null.rb +1 -1
  139. data/lib/growwer/models/seller_media.rb +1 -1
  140. data/lib/growwer/models/seller_media_flash_offer.rb +1 -1
  141. data/lib/growwer/models/seller_media_link_addition_offer.rb +1 -1
  142. data/lib/growwer/models/seller_media_link_addition_offer_pricing_options_inner.rb +1 -1
  143. data/lib/growwer/models/seller_media_post_offer.rb +1 -1
  144. data/lib/growwer/models/seller_media_post_offer_pricing_options_inner.rb +1 -1
  145. data/lib/growwer/models/seller_order.rb +1 -1
  146. data/lib/growwer/models/seller_order_briefing.rb +1 -1
  147. data/lib/growwer/models/seller_order_channel.rb +1 -1
  148. data/lib/growwer/models/seller_order_draft.rb +1 -1
  149. data/lib/growwer/models/seller_order_draft_file.rb +1 -1
  150. data/lib/growwer/models/seller_order_post_delivery.rb +1 -1
  151. data/lib/growwer/models/seller_order_project.rb +1 -1
  152. data/lib/growwer/models/seller_order_refutation.rb +1 -1
  153. data/lib/growwer/models/seller_order_rejection.rb +1 -1
  154. data/lib/growwer/models/seller_order_rejection_reason.rb +1 -1
  155. data/lib/growwer/models/seller_post_order_briefing.rb +1 -1
  156. data/lib/growwer/models/seller_transaction.rb +1 -1
  157. data/lib/growwer/models/top_up_test_wallet200_response.rb +191 -0
  158. data/lib/growwer/models/top_up_test_wallet_request.rb +165 -0
  159. data/lib/growwer/models/transaction.rb +1 -1
  160. data/lib/growwer/models/update_project_request.rb +1 -1
  161. data/lib/growwer/models/update_seller_media_request.rb +1 -1
  162. data/lib/growwer/models/update_seller_media_request_extra_services_inner.rb +1 -1
  163. data/lib/growwer/models/update_seller_media_request_link_addition_offer.rb +1 -1
  164. data/lib/growwer/models/update_seller_media_request_link_addition_offer_pricing_options_inner.rb +1 -1
  165. data/lib/growwer/models/update_seller_media_request_post_offer.rb +1 -1
  166. data/lib/growwer/models/update_seller_media_request_post_offer_pricing_options_inner.rb +1 -1
  167. data/lib/growwer/models/update_webhook_request.rb +245 -0
  168. data/lib/growwer/models/upload_file201_response.rb +1 -1
  169. data/lib/growwer/models/webhook.rb +395 -0
  170. data/lib/growwer/models/webhook_delivery.rb +365 -0
  171. data/lib/growwer/models/webhook_delivery_attempt.rb +264 -0
  172. data/lib/growwer/models/webhook_event.rb +324 -0
  173. data/lib/growwer/models/webhook_event_data.rb +104 -0
  174. data/lib/growwer/models/webhook_event_type.rb +46 -0
  175. data/lib/growwer/models/webhook_test_event_data.rb +166 -0
  176. data/lib/growwer/models/webhook_with_secret.rb +413 -0
  177. data/lib/growwer/models/withdrawal.rb +1 -1
  178. data/lib/growwer/version.rb +2 -2
  179. data/lib/growwer.rb +21 -1
  180. data/spec/api/test_helpers_api_spec.rb +74 -0
  181. data/spec/api/webhooks_api_spec.rb +154 -0
  182. data/spec/models/advance_test_order_request_spec.rb +40 -0
  183. data/spec/models/balance_low_event_data_spec.rb +42 -0
  184. data/spec/models/balance_low_event_data_wallet_spec.rb +42 -0
  185. data/spec/models/create_webhook_request_spec.rb +54 -0
  186. data/spec/models/list_webhook_deliveries200_response_spec.rb +42 -0
  187. data/spec/models/list_webhooks200_response_spec.rb +42 -0
  188. data/spec/models/order_event_data_spec.rb +36 -0
  189. data/spec/models/top_up_test_wallet200_response_spec.rb +42 -0
  190. data/spec/models/top_up_test_wallet_request_spec.rb +36 -0
  191. data/spec/models/update_webhook_request_spec.rb +60 -0
  192. data/spec/models/webhook_delivery_attempt_spec.rb +64 -0
  193. data/spec/models/webhook_delivery_spec.rb +86 -0
  194. data/spec/models/webhook_event_data_spec.rb +32 -0
  195. data/spec/models/webhook_event_spec.rb +78 -0
  196. data/spec/models/webhook_event_type_spec.rb +30 -0
  197. data/spec/models/webhook_spec.rb +100 -0
  198. data/spec/models/webhook_test_event_data_spec.rb +36 -0
  199. data/spec/models/webhook_with_secret_spec.rb +106 -0
  200. data/spec/spec_helper.rb +1 -1
  201. metadata +82 -2
@@ -0,0 +1,324 @@
1
+ =begin
2
+ #Growwer API
3
+
4
+ #The Growwer customer API. Authenticate every call with an API key created on your profile page, sent as `Authorization: Bearer <key>`. A read key can call every GET operation; writes need a read and write key and an `Idempotency-Key` header. Idempotency: use a new `Idempotency-Key` (1 to 255 printable ASCII characters without spaces) for each operation and reuse it only to retry that same operation. Keys belong to your account, not to one API key. - A successful write is stored for 30 days: a retry with the same key and the same request replays its response with `Idempotent-Replayed: true` and does nothing again. - A refused write (4xx) has no effect and releases its key: once you fix the cause, retry with the same key and the write runs. - A failed write (5xx) may have taken effect, so it is never run again under its key: a retry gets 409 `idempotency_outcome_unknown`. Check whether it took effect before retrying with a new key. - A retry while the first request is still running gets 409 `idempotency_request_in_progress`. A request still running after 5 minutes is treated as failed: a retry gets 409 `idempotency_outcome_unknown`. - The same key with a different request (method, path, query or body) gets 409 `idempotency_key_reused`. A write without the header gets 400 `idempotency_key_required`. Test mode: a test key (`gw_sk_test_` plus 43 characters) works on your account's test data alone, apart from the real catalogue: test projects, orders and files, and a test wallet that starts at 1,000.00 EUR. Every response to a test key carries `Growwer-Mode: test`, and an id of the other mode answers 404 as a missing object would. - A test order is validated and debited from the test wallet as a live one is. A simulated seller accepts it a minute later and delivers it two minutes after that; you approve the delivery or request an update. - The Test helpers top the test wallet up, move a test order on at once and reset your test data. A live key on them gets 403 `test_mode_only`. - A test key on the seller and managed service operations, on a project's catalogue writes and on media requests gets 403 `not_available_in_test_mode`. - Idempotency keys are scoped per mode: the same `Idempotency-Key` sent with a live and a test key never replays the other mode's response. Webhooks: a subscription receives the events of its mode, signed as Standard Webhooks. A subscription created with a live key gets the events of your orders and your wallet; one created with a test key gets those of your test orders and test wallet, with `mode: test`, and never a live event. `x-webhooks` lists every event Growwer POSTs and its payload; the WebhookEvent schema describes the headers, the signature and the retries. Every response carries `X-Request-Id`. Errors share one shape, `{code, message, requestId, details?}`. Money is integer cents plus a currency code and dates are ISO-8601.
5
+
6
+ The version of the OpenAPI document: 1
7
+ Contact: support@growwer.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.24.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Growwer
17
+ # What Growwer POSTs to a subscription's URL. OpenAPI 3.0, which this document follows, has no `webhooks` section: `x-webhooks` lists each event in the shape of OpenAPI 3.1's, with this envelope and the event's `data`. The headers are Standard Webhooks': `webhook-id` (the event's `id`, the same on every retry and redelivery), `webhook-timestamp` (Unix seconds of the attempt) and `webhook-signature`, space-separated `v1,<base64>` entries, each an HMAC-SHA256 with a secret's bytes (the base64 after `whsec_`) over `webhook-id.webhook-timestamp.body`; for 24 hours after a rotation there are two. Answer 2xx within 15 seconds; anything else, a redirect included, is retried with jitter, up to 10 attempts within 72 hours of the first, honouring `Retry-After` on 429 and 503 within those 72 hours. Events are delivered at least once and in no guaranteed order: dedupe by `webhook-id` and order by `createdAt`.
18
+ class WebhookEvent < ApiModelBase
19
+ attr_accessor :id
20
+
21
+ attr_accessor :type
22
+
23
+ attr_accessor :created_at
24
+
25
+ attr_accessor :api_version
26
+
27
+ # The mode of the subscription it is sent to.
28
+ attr_accessor :mode
29
+
30
+ attr_accessor :data
31
+
32
+ class EnumAttributeValidator
33
+ attr_reader :datatype
34
+ attr_reader :allowable_values
35
+
36
+ def initialize(datatype, allowable_values)
37
+ @allowable_values = allowable_values.map do |value|
38
+ case datatype.to_s
39
+ when /Integer/i
40
+ value.to_i
41
+ when /Float/i
42
+ value.to_f
43
+ else
44
+ value
45
+ end
46
+ end
47
+ end
48
+
49
+ def valid?(value)
50
+ !value || allowable_values.include?(value)
51
+ end
52
+ end
53
+
54
+ # Attribute mapping from ruby-style variable name to JSON key.
55
+ def self.attribute_map
56
+ {
57
+ :'id' => :'id',
58
+ :'type' => :'type',
59
+ :'created_at' => :'createdAt',
60
+ :'api_version' => :'apiVersion',
61
+ :'mode' => :'mode',
62
+ :'data' => :'data'
63
+ }
64
+ end
65
+
66
+ # Returns attribute mapping this model knows about
67
+ def self.acceptable_attribute_map
68
+ attribute_map
69
+ end
70
+
71
+ # Returns all the JSON keys this model knows about
72
+ def self.acceptable_attributes
73
+ acceptable_attribute_map.values
74
+ end
75
+
76
+ # Attribute type mapping.
77
+ def self.openapi_types
78
+ {
79
+ :'id' => :'String',
80
+ :'type' => :'String',
81
+ :'created_at' => :'Time',
82
+ :'api_version' => :'String',
83
+ :'mode' => :'String',
84
+ :'data' => :'WebhookEventData'
85
+ }
86
+ end
87
+
88
+ # List of attributes with nullable: true
89
+ def self.openapi_nullable
90
+ Set.new([
91
+ ])
92
+ end
93
+
94
+ # Initializes the object
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ def initialize(attributes = {})
97
+ if (!attributes.is_a?(Hash))
98
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Growwer::WebhookEvent` initialize method"
99
+ end
100
+
101
+ # check to see if the attribute exists and convert string to symbol for hash key
102
+ acceptable_attribute_map = self.class.acceptable_attribute_map
103
+ attributes = attributes.each_with_object({}) { |(k, v), h|
104
+ if (!acceptable_attribute_map.key?(k.to_sym))
105
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Growwer::WebhookEvent`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
106
+ end
107
+ h[k.to_sym] = v
108
+ }
109
+
110
+ if attributes.key?(:'id')
111
+ self.id = attributes[:'id']
112
+ else
113
+ self.id = nil
114
+ end
115
+
116
+ if attributes.key?(:'type')
117
+ self.type = attributes[:'type']
118
+ else
119
+ self.type = nil
120
+ end
121
+
122
+ if attributes.key?(:'created_at')
123
+ self.created_at = attributes[:'created_at']
124
+ else
125
+ self.created_at = nil
126
+ end
127
+
128
+ if attributes.key?(:'api_version')
129
+ self.api_version = attributes[:'api_version']
130
+ else
131
+ self.api_version = nil
132
+ end
133
+
134
+ if attributes.key?(:'mode')
135
+ self.mode = attributes[:'mode']
136
+ else
137
+ self.mode = nil
138
+ end
139
+
140
+ if attributes.key?(:'data')
141
+ self.data = attributes[:'data']
142
+ else
143
+ self.data = nil
144
+ end
145
+ end
146
+
147
+ # Show invalid properties with the reasons. Usually used together with valid?
148
+ # @return Array for valid properties with the reasons
149
+ def list_invalid_properties
150
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
151
+ invalid_properties = Array.new
152
+ if @id.nil?
153
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
154
+ end
155
+
156
+ if @type.nil?
157
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
158
+ end
159
+
160
+ if @created_at.nil?
161
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
162
+ end
163
+
164
+ if @api_version.nil?
165
+ invalid_properties.push('invalid value for "api_version", api_version cannot be nil.')
166
+ end
167
+
168
+ if @mode.nil?
169
+ invalid_properties.push('invalid value for "mode", mode cannot be nil.')
170
+ end
171
+
172
+ if @data.nil?
173
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
174
+ end
175
+
176
+ invalid_properties
177
+ end
178
+
179
+ # Check to see if the all the properties in the model are valid
180
+ # @return true if the model is valid
181
+ def valid?
182
+ warn '[DEPRECATED] the `valid?` method is obsolete'
183
+ return false if @id.nil?
184
+ return false if @type.nil?
185
+ type_validator = EnumAttributeValidator.new('String', ["order.created", "order.accepted", "order.rejected", "order.published", "order.update_requested", "order.completed", "order.cancelled", "balance.low", "webhook.test"])
186
+ return false unless type_validator.valid?(@type)
187
+ return false if @created_at.nil?
188
+ return false if @api_version.nil?
189
+ api_version_validator = EnumAttributeValidator.new('String', ["v1"])
190
+ return false unless api_version_validator.valid?(@api_version)
191
+ return false if @mode.nil?
192
+ mode_validator = EnumAttributeValidator.new('String', ["live", "test"])
193
+ return false unless mode_validator.valid?(@mode)
194
+ return false if @data.nil?
195
+ true
196
+ end
197
+
198
+ # Custom attribute writer method with validation
199
+ # @param [Object] id Value to be assigned
200
+ def id=(id)
201
+ if id.nil?
202
+ fail ArgumentError, 'id cannot be nil'
203
+ end
204
+
205
+ @id = id
206
+ end
207
+
208
+ # Custom attribute writer method checking allowed values (enum).
209
+ # @param [Object] type Object to be assigned
210
+ def type=(type)
211
+ validator = EnumAttributeValidator.new('String', ["order.created", "order.accepted", "order.rejected", "order.published", "order.update_requested", "order.completed", "order.cancelled", "balance.low", "webhook.test"])
212
+ unless validator.valid?(type)
213
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
214
+ end
215
+ @type = type
216
+ end
217
+
218
+ # Custom attribute writer method with validation
219
+ # @param [Object] created_at Value to be assigned
220
+ def created_at=(created_at)
221
+ if created_at.nil?
222
+ fail ArgumentError, 'created_at cannot be nil'
223
+ end
224
+
225
+ @created_at = created_at
226
+ end
227
+
228
+ # Custom attribute writer method checking allowed values (enum).
229
+ # @param [Object] api_version Object to be assigned
230
+ def api_version=(api_version)
231
+ validator = EnumAttributeValidator.new('String', ["v1"])
232
+ unless validator.valid?(api_version)
233
+ fail ArgumentError, "invalid value for \"api_version\", must be one of #{validator.allowable_values}."
234
+ end
235
+ @api_version = api_version
236
+ end
237
+
238
+ # Custom attribute writer method checking allowed values (enum).
239
+ # @param [Object] mode Object to be assigned
240
+ def mode=(mode)
241
+ validator = EnumAttributeValidator.new('String', ["live", "test"])
242
+ unless validator.valid?(mode)
243
+ fail ArgumentError, "invalid value for \"mode\", must be one of #{validator.allowable_values}."
244
+ end
245
+ @mode = mode
246
+ end
247
+
248
+ # Custom attribute writer method with validation
249
+ # @param [Object] data Value to be assigned
250
+ def data=(data)
251
+ if data.nil?
252
+ fail ArgumentError, 'data cannot be nil'
253
+ end
254
+
255
+ @data = data
256
+ end
257
+
258
+ # Checks equality by comparing each attribute.
259
+ # @param [Object] Object to be compared
260
+ def ==(o)
261
+ return true if self.equal?(o)
262
+ self.class == o.class &&
263
+ id == o.id &&
264
+ type == o.type &&
265
+ created_at == o.created_at &&
266
+ api_version == o.api_version &&
267
+ mode == o.mode &&
268
+ data == o.data
269
+ end
270
+
271
+ # @see the `==` method
272
+ # @param [Object] Object to be compared
273
+ def eql?(o)
274
+ self == o
275
+ end
276
+
277
+ # Calculates hash code according to all attributes.
278
+ # @return [Integer] Hash code
279
+ def hash
280
+ [id, type, created_at, api_version, mode, data].hash
281
+ end
282
+
283
+ # Builds the object from hash
284
+ # @param [Hash] attributes Model attributes in the form of hash
285
+ # @return [Object] Returns the model itself
286
+ def self.build_from_hash(attributes)
287
+ return nil unless attributes.is_a?(Hash)
288
+ attributes = attributes.transform_keys(&:to_sym)
289
+ transformed_hash = {}
290
+ openapi_types.each_pair do |key, type|
291
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
292
+ transformed_hash["#{key}"] = nil
293
+ elsif type =~ /\AArray<(.*)>/i
294
+ # check to ensure the input is an array given that the attribute
295
+ # is documented as an array but the input is not
296
+ if attributes[attribute_map[key]].is_a?(Array)
297
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
298
+ end
299
+ elsif !attributes[attribute_map[key]].nil?
300
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
301
+ end
302
+ end
303
+ new(transformed_hash)
304
+ end
305
+
306
+ # Returns the object in the form of hash
307
+ # @return [Hash] Returns the object in the form of hash
308
+ def to_hash
309
+ hash = {}
310
+ self.class.attribute_map.each_pair do |attr, param|
311
+ value = self.send(attr)
312
+ if value.nil?
313
+ is_nullable = self.class.openapi_nullable.include?(attr)
314
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
315
+ end
316
+
317
+ hash[param] = _to_hash(value)
318
+ end
319
+ hash
320
+ end
321
+
322
+ end
323
+
324
+ end
@@ -0,0 +1,104 @@
1
+ =begin
2
+ #Growwer API
3
+
4
+ #The Growwer customer API. Authenticate every call with an API key created on your profile page, sent as `Authorization: Bearer <key>`. A read key can call every GET operation; writes need a read and write key and an `Idempotency-Key` header. Idempotency: use a new `Idempotency-Key` (1 to 255 printable ASCII characters without spaces) for each operation and reuse it only to retry that same operation. Keys belong to your account, not to one API key. - A successful write is stored for 30 days: a retry with the same key and the same request replays its response with `Idempotent-Replayed: true` and does nothing again. - A refused write (4xx) has no effect and releases its key: once you fix the cause, retry with the same key and the write runs. - A failed write (5xx) may have taken effect, so it is never run again under its key: a retry gets 409 `idempotency_outcome_unknown`. Check whether it took effect before retrying with a new key. - A retry while the first request is still running gets 409 `idempotency_request_in_progress`. A request still running after 5 minutes is treated as failed: a retry gets 409 `idempotency_outcome_unknown`. - The same key with a different request (method, path, query or body) gets 409 `idempotency_key_reused`. A write without the header gets 400 `idempotency_key_required`. Test mode: a test key (`gw_sk_test_` plus 43 characters) works on your account's test data alone, apart from the real catalogue: test projects, orders and files, and a test wallet that starts at 1,000.00 EUR. Every response to a test key carries `Growwer-Mode: test`, and an id of the other mode answers 404 as a missing object would. - A test order is validated and debited from the test wallet as a live one is. A simulated seller accepts it a minute later and delivers it two minutes after that; you approve the delivery or request an update. - The Test helpers top the test wallet up, move a test order on at once and reset your test data. A live key on them gets 403 `test_mode_only`. - A test key on the seller and managed service operations, on a project's catalogue writes and on media requests gets 403 `not_available_in_test_mode`. - Idempotency keys are scoped per mode: the same `Idempotency-Key` sent with a live and a test key never replays the other mode's response. Webhooks: a subscription receives the events of its mode, signed as Standard Webhooks. A subscription created with a live key gets the events of your orders and your wallet; one created with a test key gets those of your test orders and test wallet, with `mode: test`, and never a live event. `x-webhooks` lists every event Growwer POSTs and its payload; the WebhookEvent schema describes the headers, the signature and the retries. Every response carries `X-Request-Id`. Errors share one shape, `{code, message, requestId, details?}`. Money is integer cents plus a currency code and dates are ISO-8601.
5
+
6
+ The version of the OpenAPI document: 1
7
+ Contact: support@growwer.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.24.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Growwer
17
+ # What the event is about: an OrderEventData for the `order.*` events, a BalanceLowEventData for `balance.low` and a WebhookTestEventData for `webhook.test`.
18
+ module WebhookEventData
19
+ class << self
20
+ # List of class defined in oneOf (OpenAPI v3)
21
+ def openapi_one_of
22
+ [
23
+ :'BalanceLowEventData',
24
+ :'OrderEventData',
25
+ :'WebhookTestEventData'
26
+ ]
27
+ end
28
+
29
+ # Builds the object
30
+ # @param [Mixed] Data to be matched against the list of oneOf items
31
+ # @return [Object] Returns the model or the data itself
32
+ def build(data)
33
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
34
+ # Note:
35
+ # - We do not attempt to check whether exactly one item matches.
36
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
37
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
38
+ # - TODO: scalar values are de facto behaving as if they were nullable.
39
+ # - TODO: logging when debugging is set.
40
+ openapi_one_of.each do |klass|
41
+ begin
42
+ next if klass == :AnyType # "nullable: true"
43
+ return find_and_cast_into_type(klass, data)
44
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
45
+ end
46
+ end
47
+
48
+ openapi_one_of.include?(:AnyType) ? data : nil
49
+ end
50
+
51
+ private
52
+
53
+ SchemaMismatchError = Class.new(StandardError)
54
+
55
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
56
+ def find_and_cast_into_type(klass, data)
57
+ return if data.nil?
58
+
59
+ case klass.to_s
60
+ when 'Boolean'
61
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
62
+ when 'Float'
63
+ return data if data.instance_of?(Float)
64
+ when 'Integer'
65
+ return data if data.instance_of?(Integer)
66
+ when 'Time'
67
+ return Time.parse(data)
68
+ when 'Date'
69
+ return Date.iso8601(data)
70
+ when 'String'
71
+ return data if data.instance_of?(String)
72
+ when 'Object' # "type: object"
73
+ return data if data.instance_of?(Hash)
74
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
75
+ if data.instance_of?(Array)
76
+ sub_type = Regexp.last_match[:sub_type]
77
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
78
+ end
79
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
80
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
81
+ sub_type = Regexp.last_match[:sub_type]
82
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
83
+ end
84
+ else # model
85
+ const = Growwer.const_get(klass)
86
+ if const
87
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
88
+ model = const.build(data)
89
+ return model if model
90
+ else
91
+ model = const.build_from_hash(data)
92
+ return model if model
93
+ end
94
+ end
95
+ end
96
+
97
+ raise # if no match by now, raise
98
+ rescue
99
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
100
+ end
101
+ end
102
+ end
103
+
104
+ end
@@ -0,0 +1,46 @@
1
+ =begin
2
+ #Growwer API
3
+
4
+ #The Growwer customer API. Authenticate every call with an API key created on your profile page, sent as `Authorization: Bearer <key>`. A read key can call every GET operation; writes need a read and write key and an `Idempotency-Key` header. Idempotency: use a new `Idempotency-Key` (1 to 255 printable ASCII characters without spaces) for each operation and reuse it only to retry that same operation. Keys belong to your account, not to one API key. - A successful write is stored for 30 days: a retry with the same key and the same request replays its response with `Idempotent-Replayed: true` and does nothing again. - A refused write (4xx) has no effect and releases its key: once you fix the cause, retry with the same key and the write runs. - A failed write (5xx) may have taken effect, so it is never run again under its key: a retry gets 409 `idempotency_outcome_unknown`. Check whether it took effect before retrying with a new key. - A retry while the first request is still running gets 409 `idempotency_request_in_progress`. A request still running after 5 minutes is treated as failed: a retry gets 409 `idempotency_outcome_unknown`. - The same key with a different request (method, path, query or body) gets 409 `idempotency_key_reused`. A write without the header gets 400 `idempotency_key_required`. Test mode: a test key (`gw_sk_test_` plus 43 characters) works on your account's test data alone, apart from the real catalogue: test projects, orders and files, and a test wallet that starts at 1,000.00 EUR. Every response to a test key carries `Growwer-Mode: test`, and an id of the other mode answers 404 as a missing object would. - A test order is validated and debited from the test wallet as a live one is. A simulated seller accepts it a minute later and delivers it two minutes after that; you approve the delivery or request an update. - The Test helpers top the test wallet up, move a test order on at once and reset your test data. A live key on them gets 403 `test_mode_only`. - A test key on the seller and managed service operations, on a project's catalogue writes and on media requests gets 403 `not_available_in_test_mode`. - Idempotency keys are scoped per mode: the same `Idempotency-Key` sent with a live and a test key never replays the other mode's response. Webhooks: a subscription receives the events of its mode, signed as Standard Webhooks. A subscription created with a live key gets the events of your orders and your wallet; one created with a test key gets those of your test orders and test wallet, with `mode: test`, and never a live event. `x-webhooks` lists every event Growwer POSTs and its payload; the WebhookEvent schema describes the headers, the signature and the retries. Every response carries `X-Request-Id`. Errors share one shape, `{code, message, requestId, details?}`. Money is integer cents plus a currency code and dates are ISO-8601.
5
+
6
+ The version of the OpenAPI document: 1
7
+ Contact: support@growwer.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.24.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Growwer
17
+ class WebhookEventType
18
+ ORDER_CREATED = "order.created".freeze
19
+ ORDER_ACCEPTED = "order.accepted".freeze
20
+ ORDER_REJECTED = "order.rejected".freeze
21
+ ORDER_PUBLISHED = "order.published".freeze
22
+ ORDER_UPDATE_REQUESTED = "order.update_requested".freeze
23
+ ORDER_COMPLETED = "order.completed".freeze
24
+ ORDER_CANCELLED = "order.cancelled".freeze
25
+ BALANCE_LOW = "balance.low".freeze
26
+
27
+ def self.all_vars
28
+ @all_vars ||= [ORDER_CREATED, ORDER_ACCEPTED, ORDER_REJECTED, ORDER_PUBLISHED, ORDER_UPDATE_REQUESTED, ORDER_COMPLETED, ORDER_CANCELLED, BALANCE_LOW].freeze
29
+ end
30
+
31
+ # Builds the enum from string
32
+ # @param [String] The enum value in the form of the string
33
+ # @return [String] The enum value
34
+ def self.build_from_hash(value)
35
+ new.build_from_hash(value)
36
+ end
37
+
38
+ # Builds the enum from string
39
+ # @param [String] The enum value in the form of the string
40
+ # @return [String] The enum value
41
+ def build_from_hash(value)
42
+ return value if WebhookEventType.all_vars.include?(value)
43
+ raise "Invalid ENUM value #{value} for class #WebhookEventType"
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,166 @@
1
+ =begin
2
+ #Growwer API
3
+
4
+ #The Growwer customer API. Authenticate every call with an API key created on your profile page, sent as `Authorization: Bearer <key>`. A read key can call every GET operation; writes need a read and write key and an `Idempotency-Key` header. Idempotency: use a new `Idempotency-Key` (1 to 255 printable ASCII characters without spaces) for each operation and reuse it only to retry that same operation. Keys belong to your account, not to one API key. - A successful write is stored for 30 days: a retry with the same key and the same request replays its response with `Idempotent-Replayed: true` and does nothing again. - A refused write (4xx) has no effect and releases its key: once you fix the cause, retry with the same key and the write runs. - A failed write (5xx) may have taken effect, so it is never run again under its key: a retry gets 409 `idempotency_outcome_unknown`. Check whether it took effect before retrying with a new key. - A retry while the first request is still running gets 409 `idempotency_request_in_progress`. A request still running after 5 minutes is treated as failed: a retry gets 409 `idempotency_outcome_unknown`. - The same key with a different request (method, path, query or body) gets 409 `idempotency_key_reused`. A write without the header gets 400 `idempotency_key_required`. Test mode: a test key (`gw_sk_test_` plus 43 characters) works on your account's test data alone, apart from the real catalogue: test projects, orders and files, and a test wallet that starts at 1,000.00 EUR. Every response to a test key carries `Growwer-Mode: test`, and an id of the other mode answers 404 as a missing object would. - A test order is validated and debited from the test wallet as a live one is. A simulated seller accepts it a minute later and delivers it two minutes after that; you approve the delivery or request an update. - The Test helpers top the test wallet up, move a test order on at once and reset your test data. A live key on them gets 403 `test_mode_only`. - A test key on the seller and managed service operations, on a project's catalogue writes and on media requests gets 403 `not_available_in_test_mode`. - Idempotency keys are scoped per mode: the same `Idempotency-Key` sent with a live and a test key never replays the other mode's response. Webhooks: a subscription receives the events of its mode, signed as Standard Webhooks. A subscription created with a live key gets the events of your orders and your wallet; one created with a test key gets those of your test orders and test wallet, with `mode: test`, and never a live event. `x-webhooks` lists every event Growwer POSTs and its payload; the WebhookEvent schema describes the headers, the signature and the retries. Every response carries `X-Request-Id`. Errors share one shape, `{code, message, requestId, details?}`. Money is integer cents plus a currency code and dates are ISO-8601.
5
+
6
+ The version of the OpenAPI document: 1
7
+ Contact: support@growwer.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.24.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Growwer
17
+ # The `data` of a `webhook.test` event.
18
+ class WebhookTestEventData < ApiModelBase
19
+ # The subscription it was sent to.
20
+ attr_accessor :webhook_id
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'webhook_id' => :'webhookId'
26
+ }
27
+ end
28
+
29
+ # Returns attribute mapping this model knows about
30
+ def self.acceptable_attribute_map
31
+ attribute_map
32
+ end
33
+
34
+ # Returns all the JSON keys this model knows about
35
+ def self.acceptable_attributes
36
+ acceptable_attribute_map.values
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'webhook_id' => :'String'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ ])
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ if (!attributes.is_a?(Hash))
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Growwer::WebhookTestEventData` initialize method"
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ acceptable_attribute_map = self.class.acceptable_attribute_map
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!acceptable_attribute_map.key?(k.to_sym))
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Growwer::WebhookTestEventData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
64
+ end
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:'webhook_id')
69
+ self.webhook_id = attributes[:'webhook_id']
70
+ else
71
+ self.webhook_id = nil
72
+ end
73
+ end
74
+
75
+ # Show invalid properties with the reasons. Usually used together with valid?
76
+ # @return Array for valid properties with the reasons
77
+ def list_invalid_properties
78
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
79
+ invalid_properties = Array.new
80
+ if @webhook_id.nil?
81
+ invalid_properties.push('invalid value for "webhook_id", webhook_id cannot be nil.')
82
+ end
83
+
84
+ invalid_properties
85
+ end
86
+
87
+ # Check to see if the all the properties in the model are valid
88
+ # @return true if the model is valid
89
+ def valid?
90
+ warn '[DEPRECATED] the `valid?` method is obsolete'
91
+ return false if @webhook_id.nil?
92
+ true
93
+ end
94
+
95
+ # Custom attribute writer method with validation
96
+ # @param [Object] webhook_id Value to be assigned
97
+ def webhook_id=(webhook_id)
98
+ if webhook_id.nil?
99
+ fail ArgumentError, 'webhook_id cannot be nil'
100
+ end
101
+
102
+ @webhook_id = webhook_id
103
+ end
104
+
105
+ # Checks equality by comparing each attribute.
106
+ # @param [Object] Object to be compared
107
+ def ==(o)
108
+ return true if self.equal?(o)
109
+ self.class == o.class &&
110
+ webhook_id == o.webhook_id
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [webhook_id].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ return nil unless attributes.is_a?(Hash)
130
+ attributes = attributes.transform_keys(&:to_sym)
131
+ transformed_hash = {}
132
+ openapi_types.each_pair do |key, type|
133
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
134
+ transformed_hash["#{key}"] = nil
135
+ elsif type =~ /\AArray<(.*)>/i
136
+ # check to ensure the input is an array given that the attribute
137
+ # is documented as an array but the input is not
138
+ if attributes[attribute_map[key]].is_a?(Array)
139
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
140
+ end
141
+ elsif !attributes[attribute_map[key]].nil?
142
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
143
+ end
144
+ end
145
+ new(transformed_hash)
146
+ end
147
+
148
+ # Returns the object in the form of hash
149
+ # @return [Hash] Returns the object in the form of hash
150
+ def to_hash
151
+ hash = {}
152
+ self.class.attribute_map.each_pair do |attr, param|
153
+ value = self.send(attr)
154
+ if value.nil?
155
+ is_nullable = self.class.openapi_nullable.include?(attr)
156
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
157
+ end
158
+
159
+ hash[param] = _to_hash(value)
160
+ end
161
+ hash
162
+ end
163
+
164
+ end
165
+
166
+ end