license_manager 0.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 (323) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +5 -0
  3. data/Gemfile +9 -0
  4. data/LICENSE +201 -0
  5. data/README.md +96 -0
  6. data/Rakefile +10 -0
  7. data/docs/ConnectStripe.md +18 -0
  8. data/docs/CreateCustomer.md +20 -0
  9. data/docs/CreateIntegrationMapping.md +20 -0
  10. data/docs/CreateLicense.md +36 -0
  11. data/docs/CreatePolicy.md +30 -0
  12. data/docs/CreatePortalLink.md +18 -0
  13. data/docs/CreateProduct.md +20 -0
  14. data/docs/CreateProductWithPolicy.md +24 -0
  15. data/docs/CreateRelease.md +20 -0
  16. data/docs/CreateToken.md +20 -0
  17. data/docs/Customer.md +30 -0
  18. data/docs/CustomerList.md +20 -0
  19. data/docs/CustomersApi.md +385 -0
  20. data/docs/Error.md +18 -0
  21. data/docs/ErrorError.md +22 -0
  22. data/docs/ErrorErrorIssuesInner.md +20 -0
  23. data/docs/ErrorErrorIssuesInnerPathInner.md +15 -0
  24. data/docs/Event.md +34 -0
  25. data/docs/EventActor.md +55 -0
  26. data/docs/EventActorOneOf.md +26 -0
  27. data/docs/EventActorOneOf1.md +24 -0
  28. data/docs/EventActorOneOf2.md +22 -0
  29. data/docs/EventActorOneOf3.md +18 -0
  30. data/docs/EventActorOneOf4.md +22 -0
  31. data/docs/EventList.md +20 -0
  32. data/docs/EventMachine.md +22 -0
  33. data/docs/EventType.md +15 -0
  34. data/docs/EventsApi.md +173 -0
  35. data/docs/FixedMaxVersion.md +20 -0
  36. data/docs/Integration.md +38 -0
  37. data/docs/IntegrationMapping.md +38 -0
  38. data/docs/IntegrationStatus.md +15 -0
  39. data/docs/IntegrationsApi.md +587 -0
  40. data/docs/License.md +50 -0
  41. data/docs/LicenseList.md +20 -0
  42. data/docs/LicenseMaxVersion.md +22 -0
  43. data/docs/LicenseMaxVersionInput.md +22 -0
  44. data/docs/LicenseStats.md +26 -0
  45. data/docs/LicenseStatsActivationsByMachineInner.md +24 -0
  46. data/docs/LicenseStatsActivationsByVersionInner.md +20 -0
  47. data/docs/LicenseStatus.md +15 -0
  48. data/docs/LicenseToken.md +18 -0
  49. data/docs/LicensesApi.md +817 -0
  50. data/docs/ListPolicyEventsTypeParameter.md +15 -0
  51. data/docs/ListStripePrices200Response.md +18 -0
  52. data/docs/LockMaxVersion.md +22 -0
  53. data/docs/LockMaxVersionMajorAfter.md +49 -0
  54. data/docs/LockMaxVersionMajorAfterOneOf.md +20 -0
  55. data/docs/LockMaxVersionMajorAfterOneOf1.md +20 -0
  56. data/docs/LockMaxVersionMinorAfter.md +20 -0
  57. data/docs/Machine.md +36 -0
  58. data/docs/MachineList.md +20 -0
  59. data/docs/MachinesApi.md +246 -0
  60. data/docs/Pagination.md +24 -0
  61. data/docs/PoliciesApi.md +388 -0
  62. data/docs/Policy.md +40 -0
  63. data/docs/PolicyDuration.md +20 -0
  64. data/docs/PolicyList.md +20 -0
  65. data/docs/PolicyMaxVersion.md +24 -0
  66. data/docs/PolicySettings.md +24 -0
  67. data/docs/PolicySettingsDuration.md +20 -0
  68. data/docs/PolicySettingsDurationAnyOf.md +20 -0
  69. data/docs/PolicySettingsDurationAnyOf1.md +20 -0
  70. data/docs/PolicySettingsMaxVersion.md +24 -0
  71. data/docs/Portal.md +30 -0
  72. data/docs/PortalApi.md +289 -0
  73. data/docs/PortalLink.md +22 -0
  74. data/docs/PortalNotFound.md +22 -0
  75. data/docs/PortalSettings.md +26 -0
  76. data/docs/Price.md +20 -0
  77. data/docs/PriceInput.md +20 -0
  78. data/docs/Product.md +32 -0
  79. data/docs/ProductList.md +20 -0
  80. data/docs/ProductStats.md +54 -0
  81. data/docs/ProductStatsActivationsByVersionInner.md +20 -0
  82. data/docs/ProductStatsActiveMachinesByPlatformInner.md +20 -0
  83. data/docs/ProductStatsActiveMachinesByVersionInner.md +20 -0
  84. data/docs/ProductStatsNewLicensesByPolicyInner.md +22 -0
  85. data/docs/ProductsApi.md +666 -0
  86. data/docs/Release.md +28 -0
  87. data/docs/ReleaseList.md +20 -0
  88. data/docs/ReleasesApi.md +388 -0
  89. data/docs/RequestPortalLink.md +20 -0
  90. data/docs/Revenue.md +34 -0
  91. data/docs/SendLicenseKeys.md +18 -0
  92. data/docs/SendPortalLink.md +18 -0
  93. data/docs/SigningKey.md +27 -0
  94. data/docs/StripeIntegration.md +26 -0
  95. data/docs/StripePermission.md +22 -0
  96. data/docs/StripePrice.md +28 -0
  97. data/docs/Token.md +24 -0
  98. data/docs/TokensApi.md +235 -0
  99. data/docs/UpdateCustomer.md +20 -0
  100. data/docs/UpdateIntegrationMapping.md +18 -0
  101. data/docs/UpdateLicense.md +28 -0
  102. data/docs/UpdatePolicy.md +30 -0
  103. data/docs/UpdateProduct.md +22 -0
  104. data/docs/UpdateProductPortal.md +26 -0
  105. data/docs/UpdateRelease.md +20 -0
  106. data/docs/ValidateKey.md +26 -0
  107. data/docs/ValidateKeyError.md +18 -0
  108. data/docs/ValidateKeyErrorError.md +24 -0
  109. data/git_push.sh +54 -0
  110. data/lib/license_manager/api/customers_api.rb +398 -0
  111. data/lib/license_manager/api/events_api.rb +207 -0
  112. data/lib/license_manager/api/integrations_api.rb +559 -0
  113. data/lib/license_manager/api/licenses_api.rb +885 -0
  114. data/lib/license_manager/api/machines_api.rb +257 -0
  115. data/lib/license_manager/api/policies_api.rb +412 -0
  116. data/lib/license_manager/api/portal_api.rb +310 -0
  117. data/lib/license_manager/api/products_api.rb +653 -0
  118. data/lib/license_manager/api/releases_api.rb +408 -0
  119. data/lib/license_manager/api/tokens_api.rb +244 -0
  120. data/lib/license_manager/api_client.rb +441 -0
  121. data/lib/license_manager/api_error.rb +58 -0
  122. data/lib/license_manager/api_model_base.rb +88 -0
  123. data/lib/license_manager/configuration.rb +400 -0
  124. data/lib/license_manager/models/connect_stripe.rb +187 -0
  125. data/lib/license_manager/models/create_customer.rb +222 -0
  126. data/lib/license_manager/models/create_integration_mapping.rb +222 -0
  127. data/lib/license_manager/models/create_license.rb +361 -0
  128. data/lib/license_manager/models/create_policy.rb +347 -0
  129. data/lib/license_manager/models/create_portal_link.rb +196 -0
  130. data/lib/license_manager/models/create_product.rb +244 -0
  131. data/lib/license_manager/models/create_product_with_policy.rb +270 -0
  132. data/lib/license_manager/models/create_release.rb +208 -0
  133. data/lib/license_manager/models/create_token.rb +237 -0
  134. data/lib/license_manager/models/customer.rb +308 -0
  135. data/lib/license_manager/models/customer_list.rb +206 -0
  136. data/lib/license_manager/models/error.rb +177 -0
  137. data/lib/license_manager/models/error_error.rb +215 -0
  138. data/lib/license_manager/models/error_error_issues_inner.rb +205 -0
  139. data/lib/license_manager/models/error_error_issues_inner_path_inner.rb +103 -0
  140. data/lib/license_manager/models/event.rb +340 -0
  141. data/lib/license_manager/models/event_actor.rb +108 -0
  142. data/lib/license_manager/models/event_actor_one_of.rb +251 -0
  143. data/lib/license_manager/models/event_actor_one_of1.rb +239 -0
  144. data/lib/license_manager/models/event_actor_one_of2.rb +257 -0
  145. data/lib/license_manager/models/event_actor_one_of3.rb +201 -0
  146. data/lib/license_manager/models/event_actor_one_of4.rb +243 -0
  147. data/lib/license_manager/models/event_list.rb +206 -0
  148. data/lib/license_manager/models/event_machine.rb +216 -0
  149. data/lib/license_manager/models/event_type.rb +46 -0
  150. data/lib/license_manager/models/fixed_max_version.rb +240 -0
  151. data/lib/license_manager/models/integration.rb +412 -0
  152. data/lib/license_manager/models/integration_mapping.rb +435 -0
  153. data/lib/license_manager/models/integration_status.rb +42 -0
  154. data/lib/license_manager/models/license.rb +542 -0
  155. data/lib/license_manager/models/license_list.rb +206 -0
  156. data/lib/license_manager/models/license_max_version.rb +208 -0
  157. data/lib/license_manager/models/license_max_version_input.rb +202 -0
  158. data/lib/license_manager/models/license_stats.rb +292 -0
  159. data/lib/license_manager/models/license_stats_activations_by_machine_inner.rb +244 -0
  160. data/lib/license_manager/models/license_stats_activations_by_version_inner.rb +206 -0
  161. data/lib/license_manager/models/license_status.rb +42 -0
  162. data/lib/license_manager/models/license_token.rb +178 -0
  163. data/lib/license_manager/models/list_policy_events_type_parameter.rb +104 -0
  164. data/lib/license_manager/models/list_stripe_prices200_response.rb +179 -0
  165. data/lib/license_manager/models/lock_max_version.rb +240 -0
  166. data/lib/license_manager/models/lock_max_version_major_after.rb +105 -0
  167. data/lib/license_manager/models/lock_max_version_major_after_one_of.rb +245 -0
  168. data/lib/license_manager/models/lock_max_version_major_after_one_of1.rb +246 -0
  169. data/lib/license_manager/models/lock_max_version_minor_after.rb +104 -0
  170. data/lib/license_manager/models/machine.rb +383 -0
  171. data/lib/license_manager/models/machine_list.rb +206 -0
  172. data/lib/license_manager/models/pagination.rb +260 -0
  173. data/lib/license_manager/models/policy.rb +425 -0
  174. data/lib/license_manager/models/policy_duration.rb +104 -0
  175. data/lib/license_manager/models/policy_list.rb +206 -0
  176. data/lib/license_manager/models/policy_max_version.rb +104 -0
  177. data/lib/license_manager/models/policy_settings.rb +244 -0
  178. data/lib/license_manager/models/policy_settings_duration.rb +104 -0
  179. data/lib/license_manager/models/policy_settings_duration_any_of.rb +245 -0
  180. data/lib/license_manager/models/policy_settings_duration_any_of1.rb +246 -0
  181. data/lib/license_manager/models/policy_settings_max_version.rb +104 -0
  182. data/lib/license_manager/models/portal.rb +281 -0
  183. data/lib/license_manager/models/portal_link.rb +232 -0
  184. data/lib/license_manager/models/portal_not_found.rb +204 -0
  185. data/lib/license_manager/models/portal_settings.rb +304 -0
  186. data/lib/license_manager/models/price.rb +206 -0
  187. data/lib/license_manager/models/price_input.rb +224 -0
  188. data/lib/license_manager/models/product.rb +333 -0
  189. data/lib/license_manager/models/product_list.rb +206 -0
  190. data/lib/license_manager/models/product_stats.rb +682 -0
  191. data/lib/license_manager/models/product_stats_activations_by_version_inner.rb +193 -0
  192. data/lib/license_manager/models/product_stats_active_machines_by_platform_inner.rb +190 -0
  193. data/lib/license_manager/models/product_stats_active_machines_by_version_inner.rb +190 -0
  194. data/lib/license_manager/models/product_stats_new_licenses_by_policy_inner.rb +235 -0
  195. data/lib/license_manager/models/release.rb +308 -0
  196. data/lib/license_manager/models/release_list.rb +206 -0
  197. data/lib/license_manager/models/request_portal_link.rb +216 -0
  198. data/lib/license_manager/models/revenue.rb +401 -0
  199. data/lib/license_manager/models/send_license_keys.rb +198 -0
  200. data/lib/license_manager/models/send_portal_link.rb +187 -0
  201. data/lib/license_manager/models/signing_key.rb +282 -0
  202. data/lib/license_manager/models/stripe_integration.rb +276 -0
  203. data/lib/license_manager/models/stripe_permission.rb +253 -0
  204. data/lib/license_manager/models/stripe_price.rb +280 -0
  205. data/lib/license_manager/models/token.rb +274 -0
  206. data/lib/license_manager/models/update_customer.rb +215 -0
  207. data/lib/license_manager/models/update_integration_mapping.rb +186 -0
  208. data/lib/license_manager/models/update_license.rb +268 -0
  209. data/lib/license_manager/models/update_policy.rb +340 -0
  210. data/lib/license_manager/models/update_product.rb +246 -0
  211. data/lib/license_manager/models/update_product_portal.rb +274 -0
  212. data/lib/license_manager/models/update_release.rb +201 -0
  213. data/lib/license_manager/models/validate_key.rb +362 -0
  214. data/lib/license_manager/models/validate_key_error.rb +177 -0
  215. data/lib/license_manager/models/validate_key_error_error.rb +226 -0
  216. data/lib/license_manager/version.rb +15 -0
  217. data/lib/license_manager.rb +142 -0
  218. data/license_manager.gemspec +41 -0
  219. data/openapi.json +9825 -0
  220. data/spec/api/customers_api_spec.rb +102 -0
  221. data/spec/api/events_api_spec.rb +68 -0
  222. data/spec/api/integrations_api_spec.rb +134 -0
  223. data/spec/api/licenses_api_spec.rb +200 -0
  224. data/spec/api/machines_api_spec.rb +77 -0
  225. data/spec/api/policies_api_spec.rb +105 -0
  226. data/spec/api/portal_api_spec.rb +87 -0
  227. data/spec/api/products_api_spec.rb +148 -0
  228. data/spec/api/releases_api_spec.rb +105 -0
  229. data/spec/api/tokens_api_spec.rb +74 -0
  230. data/spec/models/connect_stripe_spec.rb +36 -0
  231. data/spec/models/create_customer_spec.rb +42 -0
  232. data/spec/models/create_integration_mapping_spec.rb +42 -0
  233. data/spec/models/create_license_spec.rb +90 -0
  234. data/spec/models/create_policy_spec.rb +72 -0
  235. data/spec/models/create_portal_link_spec.rb +36 -0
  236. data/spec/models/create_product_spec.rb +42 -0
  237. data/spec/models/create_product_with_policy_spec.rb +54 -0
  238. data/spec/models/create_release_spec.rb +42 -0
  239. data/spec/models/create_token_spec.rb +46 -0
  240. data/spec/models/customer_list_spec.rb +42 -0
  241. data/spec/models/customer_spec.rb +72 -0
  242. data/spec/models/error_error_issues_inner_path_inner_spec.rb +21 -0
  243. data/spec/models/error_error_issues_inner_spec.rb +42 -0
  244. data/spec/models/error_error_spec.rb +48 -0
  245. data/spec/models/error_spec.rb +36 -0
  246. data/spec/models/event_actor_one_of1_spec.rb +58 -0
  247. data/spec/models/event_actor_one_of2_spec.rb +56 -0
  248. data/spec/models/event_actor_one_of3_spec.rb +40 -0
  249. data/spec/models/event_actor_one_of4_spec.rb +56 -0
  250. data/spec/models/event_actor_one_of_spec.rb +64 -0
  251. data/spec/models/event_actor_spec.rb +32 -0
  252. data/spec/models/event_list_spec.rb +42 -0
  253. data/spec/models/event_machine_spec.rb +48 -0
  254. data/spec/models/event_spec.rb +84 -0
  255. data/spec/models/event_type_spec.rb +30 -0
  256. data/spec/models/fixed_max_version_spec.rb +46 -0
  257. data/spec/models/integration_mapping_spec.rb +100 -0
  258. data/spec/models/integration_spec.rb +100 -0
  259. data/spec/models/integration_status_spec.rb +30 -0
  260. data/spec/models/license_list_spec.rb +42 -0
  261. data/spec/models/license_max_version_input_spec.rb +48 -0
  262. data/spec/models/license_max_version_spec.rb +48 -0
  263. data/spec/models/license_spec.rb +132 -0
  264. data/spec/models/license_stats_activations_by_machine_inner_spec.rb +54 -0
  265. data/spec/models/license_stats_activations_by_version_inner_spec.rb +42 -0
  266. data/spec/models/license_stats_spec.rb +60 -0
  267. data/spec/models/license_status_spec.rb +30 -0
  268. data/spec/models/license_token_spec.rb +36 -0
  269. data/spec/models/list_policy_events_type_parameter_spec.rb +21 -0
  270. data/spec/models/list_stripe_prices200_response_spec.rb +36 -0
  271. data/spec/models/lock_max_version_major_after_one_of1_spec.rb +46 -0
  272. data/spec/models/lock_max_version_major_after_one_of_spec.rb +46 -0
  273. data/spec/models/lock_max_version_major_after_spec.rb +32 -0
  274. data/spec/models/lock_max_version_minor_after_spec.rb +21 -0
  275. data/spec/models/lock_max_version_spec.rb +52 -0
  276. data/spec/models/machine_list_spec.rb +42 -0
  277. data/spec/models/machine_spec.rb +94 -0
  278. data/spec/models/pagination_spec.rb +54 -0
  279. data/spec/models/policy_duration_spec.rb +21 -0
  280. data/spec/models/policy_list_spec.rb +42 -0
  281. data/spec/models/policy_max_version_spec.rb +21 -0
  282. data/spec/models/policy_settings_duration_any_of1_spec.rb +46 -0
  283. data/spec/models/policy_settings_duration_any_of_spec.rb +46 -0
  284. data/spec/models/policy_settings_duration_spec.rb +21 -0
  285. data/spec/models/policy_settings_max_version_spec.rb +21 -0
  286. data/spec/models/policy_settings_spec.rb +54 -0
  287. data/spec/models/policy_spec.rb +102 -0
  288. data/spec/models/portal_link_spec.rb +48 -0
  289. data/spec/models/portal_not_found_spec.rb +48 -0
  290. data/spec/models/portal_settings_spec.rb +60 -0
  291. data/spec/models/portal_spec.rb +72 -0
  292. data/spec/models/price_input_spec.rb +42 -0
  293. data/spec/models/price_spec.rb +42 -0
  294. data/spec/models/product_list_spec.rb +42 -0
  295. data/spec/models/product_spec.rb +78 -0
  296. data/spec/models/product_stats_activations_by_version_inner_spec.rb +42 -0
  297. data/spec/models/product_stats_active_machines_by_platform_inner_spec.rb +42 -0
  298. data/spec/models/product_stats_active_machines_by_version_inner_spec.rb +42 -0
  299. data/spec/models/product_stats_new_licenses_by_policy_inner_spec.rb +48 -0
  300. data/spec/models/product_stats_spec.rb +144 -0
  301. data/spec/models/release_list_spec.rb +42 -0
  302. data/spec/models/release_spec.rb +66 -0
  303. data/spec/models/request_portal_link_spec.rb +42 -0
  304. data/spec/models/revenue_spec.rb +84 -0
  305. data/spec/models/send_license_keys_spec.rb +36 -0
  306. data/spec/models/send_portal_link_spec.rb +36 -0
  307. data/spec/models/signing_key_spec.rb +58 -0
  308. data/spec/models/stripe_integration_spec.rb +60 -0
  309. data/spec/models/stripe_permission_spec.rb +52 -0
  310. data/spec/models/stripe_price_spec.rb +66 -0
  311. data/spec/models/token_spec.rb +62 -0
  312. data/spec/models/update_customer_spec.rb +42 -0
  313. data/spec/models/update_integration_mapping_spec.rb +36 -0
  314. data/spec/models/update_license_spec.rb +66 -0
  315. data/spec/models/update_policy_spec.rb +72 -0
  316. data/spec/models/update_product_portal_spec.rb +60 -0
  317. data/spec/models/update_product_spec.rb +48 -0
  318. data/spec/models/update_release_spec.rb +42 -0
  319. data/spec/models/validate_key_error_error_spec.rb +54 -0
  320. data/spec/models/validate_key_error_spec.rb +36 -0
  321. data/spec/models/validate_key_spec.rb +60 -0
  322. data/spec/spec_helper.rb +111 -0
  323. metadata +532 -0
@@ -0,0 +1,653 @@
1
+ =begin
2
+ #LicenseManager API
3
+
4
+ #Public API. Authenticate with an organization API key, or with a token scoped to a customer, license or machine on the endpoints that accept one. ## Conventions - **Errors** answer `{ \"error\": { \"code\", \"message\" } }`. Branch on `code`, which is stable, not on `message`. Each response lists the codes it can return, except `404`, which answers `not_found` unless it says otherwise. Unexpected errors answer `500` with `internal_error`. - **Validation** errors answer `422`, not `400`, with the `validation_error` code and an `issues` array giving the `path` and `message` of each invalid value. - **Unknown body fields are ignored**, not rejected: sending a field an endpoint doesn't accept, like `policyId` to `updateLicense`, changes nothing and doesn't fail. - **Strings** are trimmed before they're validated and stored. Emails are stored lower cased. - **Updates** only change the fields that are sent. A field sent as `null` is cleared, when it can be. - **Dates** can be sent with any offset, and are always returned in UTC, like `2026-01-15T09:30:00.000Z`. Calendar months and days are counted in UTC. - **Ids** are 8 letters and digits, after `test_` for test products and their resources. - **Lists** are paginated with `page` and `pageSize`. Items with the same value for the `sort` field are ordered by id, so pages are stable, but items created or deleted between two requests shift the pages. Items without a value for the `sort` field come last in ascending order, and first in descending order, unless the endpoint says otherwise. - **Test products** are sandboxes of a live product. Test API keys only reach test products, live API keys only live ones: the others answer `404`, as if they didn't exist. Sessions and tokens reach both.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.26.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module LicenseManager
16
+ class ProductsApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Create a product
23
+ # Without a `slug`, the product gets one derived from its name: lower cased, without accents and special characters (`Élan Pro 2!` becomes `elan-pro-2`). When another product of the organization already uses it, a dash and 3 random lowercase letters or digits are appended (`elan-pro-2-k3f`), until the slug is free. An explicit `slug` is used as is: the request fails with a `409` when it's taken, it's never changed. Slug uniqueness is enforced by the database, so when concurrent requests end up with the same slug, only one succeeds and the others get a `409`, even without an explicit `slug`. Retrying such a request without a `slug` derives a new one. The product is created with its default policy, named `Default policy` with the `default` slug, whose settings are given by `defaultPolicy`. Omitted settings default to licenses that never expire, on a single machine, offline for one week, for every version of the product. Unlike `createPolicy`, where `maxMachines` defaults to no limit. With `isTestFromProductId`, the product is a test product: its id, its slug, and the ids, slugs and license keys of its resources start with `test_` (`TEST-` for license keys), and only test API keys reach it. It starts with copies of the policies, releases and portal settings of the live product, `defaultPolicy` is ignored. Later changes to the live product aren't copied: reset the test product to copy them again. Test API keys can only create test products, live API keys only live ones. **Required role permission**: `product:create` when called with a session, granted by the member's role. API keys aren't limited by roles.
24
+ # @param create_product_with_policy [CreateProductWithPolicy]
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [Product]
27
+ def create_product(create_product_with_policy, opts = {})
28
+ data, _status_code, _headers = create_product_with_http_info(create_product_with_policy, opts)
29
+ data
30
+ end
31
+
32
+ # Create a product
33
+ # Without a `slug`, the product gets one derived from its name: lower cased, without accents and special characters (`Élan Pro 2!` becomes `elan-pro-2`). When another product of the organization already uses it, a dash and 3 random lowercase letters or digits are appended (`elan-pro-2-k3f`), until the slug is free. An explicit `slug` is used as is: the request fails with a `409` when it's taken, it's never changed. Slug uniqueness is enforced by the database, so when concurrent requests end up with the same slug, only one succeeds and the others get a `409`, even without an explicit `slug`. Retrying such a request without a `slug` derives a new one. The product is created with its default policy, named `Default policy` with the `default` slug, whose settings are given by `defaultPolicy`. Omitted settings default to licenses that never expire, on a single machine, offline for one week, for every version of the product. Unlike `createPolicy`, where `maxMachines` defaults to no limit. With `isTestFromProductId`, the product is a test product: its id, its slug, and the ids, slugs and license keys of its resources start with `test_` (`TEST-` for license keys), and only test API keys reach it. It starts with copies of the policies, releases and portal settings of the live product, `defaultPolicy` is ignored. Later changes to the live product aren't copied: reset the test product to copy them again. Test API keys can only create test products, live API keys only live ones. **Required role permission**: `product:create` when called with a session, granted by the member's role. API keys aren't limited by roles.
34
+ # @param create_product_with_policy [CreateProductWithPolicy]
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(Product, Integer, Hash)>] Product data, response status code and response headers
37
+ def create_product_with_http_info(create_product_with_policy, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: ProductsApi.create_product ...'
40
+ end
41
+ # verify the required parameter 'create_product_with_policy' is set
42
+ if @api_client.config.client_side_validation && create_product_with_policy.nil?
43
+ fail ArgumentError, "Missing the required parameter 'create_product_with_policy' when calling ProductsApi.create_product"
44
+ end
45
+ # resource path
46
+ local_var_path = '/v1/products'
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
55
+ # HTTP header 'Content-Type'
56
+ content_type = @api_client.select_header_content_type(['application/json'])
57
+ if !content_type.nil?
58
+ header_params['Content-Type'] = content_type
59
+ end
60
+
61
+ # form parameters
62
+ form_params = opts[:form_params] || {}
63
+
64
+ # http body (model)
65
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(create_product_with_policy)
66
+
67
+ # return_type
68
+ return_type = opts[:debug_return_type] || 'Product'
69
+
70
+ # auth_names
71
+ auth_names = opts[:debug_auth_names] || ['apiKey']
72
+
73
+ new_options = opts.merge(
74
+ :operation => :"ProductsApi.create_product",
75
+ :header_params => header_params,
76
+ :query_params => query_params,
77
+ :form_params => form_params,
78
+ :body => post_body,
79
+ :auth_names => auth_names,
80
+ :return_type => return_type
81
+ )
82
+
83
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
84
+ if @api_client.config.debugging
85
+ @api_client.config.logger.debug "API called: ProductsApi#create_product\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
86
+ end
87
+ return data, status_code, headers
88
+ end
89
+
90
+ # Delete a product
91
+ # Deletes the product along with its policies, customers and releases, and its test products with everything they hold. A live product that licenses belong to can't be deleted: delete them first. A test product can always be deleted, along with its licenses and machines. The events of the deleted policies and licenses can no longer be listed. **Required role permission**: `product:delete` when called with a session, granted by the member's role. API keys aren't limited by roles.
92
+ # @param id [String]
93
+ # @param [Hash] opts the optional parameters
94
+ # @return [nil]
95
+ def delete_product(id, opts = {})
96
+ delete_product_with_http_info(id, opts)
97
+ nil
98
+ end
99
+
100
+ # Delete a product
101
+ # Deletes the product along with its policies, customers and releases, and its test products with everything they hold. A live product that licenses belong to can&#39;t be deleted: delete them first. A test product can always be deleted, along with its licenses and machines. The events of the deleted policies and licenses can no longer be listed. **Required role permission**: &#x60;product:delete&#x60; when called with a session, granted by the member&#39;s role. API keys aren&#39;t limited by roles.
102
+ # @param id [String]
103
+ # @param [Hash] opts the optional parameters
104
+ # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
105
+ def delete_product_with_http_info(id, opts = {})
106
+ if @api_client.config.debugging
107
+ @api_client.config.logger.debug 'Calling API: ProductsApi.delete_product ...'
108
+ end
109
+ # verify the required parameter 'id' is set
110
+ if @api_client.config.client_side_validation && id.nil?
111
+ fail ArgumentError, "Missing the required parameter 'id' when calling ProductsApi.delete_product"
112
+ end
113
+ # resource path
114
+ local_var_path = '/v1/products/{id}'.sub('{id}', CGI.escape(id.to_s))
115
+
116
+ # query parameters
117
+ query_params = opts[:query_params] || {}
118
+
119
+ # header parameters
120
+ header_params = opts[:header_params] || {}
121
+ # HTTP header 'Accept' (if needed)
122
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
123
+
124
+ # form parameters
125
+ form_params = opts[:form_params] || {}
126
+
127
+ # http body (model)
128
+ post_body = opts[:debug_body]
129
+
130
+ # return_type
131
+ return_type = opts[:debug_return_type]
132
+
133
+ # auth_names
134
+ auth_names = opts[:debug_auth_names] || ['apiKey']
135
+
136
+ new_options = opts.merge(
137
+ :operation => :"ProductsApi.delete_product",
138
+ :header_params => header_params,
139
+ :query_params => query_params,
140
+ :form_params => form_params,
141
+ :body => post_body,
142
+ :auth_names => auth_names,
143
+ :return_type => return_type
144
+ )
145
+
146
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
147
+ if @api_client.config.debugging
148
+ @api_client.config.logger.debug "API called: ProductsApi#delete_product\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
149
+ end
150
+ return data, status_code, headers
151
+ end
152
+
153
+ # Delete a product logo
154
+ # Removes the logo of the product, and deletes its image. Succeeds when the product has no logo. **Required role permission**: `product:update` when called with a session, granted by the member's role. API keys aren't limited by roles.
155
+ # @param id [String]
156
+ # @param [Hash] opts the optional parameters
157
+ # @return [Product]
158
+ def delete_product_logo(id, opts = {})
159
+ data, _status_code, _headers = delete_product_logo_with_http_info(id, opts)
160
+ data
161
+ end
162
+
163
+ # Delete a product logo
164
+ # Removes the logo of the product, and deletes its image. Succeeds when the product has no logo. **Required role permission**: &#x60;product:update&#x60; when called with a session, granted by the member&#39;s role. API keys aren&#39;t limited by roles.
165
+ # @param id [String]
166
+ # @param [Hash] opts the optional parameters
167
+ # @return [Array<(Product, Integer, Hash)>] Product data, response status code and response headers
168
+ def delete_product_logo_with_http_info(id, opts = {})
169
+ if @api_client.config.debugging
170
+ @api_client.config.logger.debug 'Calling API: ProductsApi.delete_product_logo ...'
171
+ end
172
+ # verify the required parameter 'id' is set
173
+ if @api_client.config.client_side_validation && id.nil?
174
+ fail ArgumentError, "Missing the required parameter 'id' when calling ProductsApi.delete_product_logo"
175
+ end
176
+ # resource path
177
+ local_var_path = '/v1/products/{id}/logo'.sub('{id}', CGI.escape(id.to_s))
178
+
179
+ # query parameters
180
+ query_params = opts[:query_params] || {}
181
+
182
+ # header parameters
183
+ header_params = opts[:header_params] || {}
184
+ # HTTP header 'Accept' (if needed)
185
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
186
+
187
+ # form parameters
188
+ form_params = opts[:form_params] || {}
189
+
190
+ # http body (model)
191
+ post_body = opts[:debug_body]
192
+
193
+ # return_type
194
+ return_type = opts[:debug_return_type] || 'Product'
195
+
196
+ # auth_names
197
+ auth_names = opts[:debug_auth_names] || ['apiKey']
198
+
199
+ new_options = opts.merge(
200
+ :operation => :"ProductsApi.delete_product_logo",
201
+ :header_params => header_params,
202
+ :query_params => query_params,
203
+ :form_params => form_params,
204
+ :body => post_body,
205
+ :auth_names => auth_names,
206
+ :return_type => return_type
207
+ )
208
+
209
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
210
+ if @api_client.config.debugging
211
+ @api_client.config.logger.debug "API called: ProductsApi#delete_product_logo\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
212
+ end
213
+ return data, status_code, headers
214
+ end
215
+
216
+ # Get a product
217
+ # @param id [String]
218
+ # @param [Hash] opts the optional parameters
219
+ # @return [Product]
220
+ def get_product(id, opts = {})
221
+ data, _status_code, _headers = get_product_with_http_info(id, opts)
222
+ data
223
+ end
224
+
225
+ # Get a product
226
+ # @param id [String]
227
+ # @param [Hash] opts the optional parameters
228
+ # @return [Array<(Product, Integer, Hash)>] Product data, response status code and response headers
229
+ def get_product_with_http_info(id, opts = {})
230
+ if @api_client.config.debugging
231
+ @api_client.config.logger.debug 'Calling API: ProductsApi.get_product ...'
232
+ end
233
+ # verify the required parameter 'id' is set
234
+ if @api_client.config.client_side_validation && id.nil?
235
+ fail ArgumentError, "Missing the required parameter 'id' when calling ProductsApi.get_product"
236
+ end
237
+ # resource path
238
+ local_var_path = '/v1/products/{id}'.sub('{id}', CGI.escape(id.to_s))
239
+
240
+ # query parameters
241
+ query_params = opts[:query_params] || {}
242
+
243
+ # header parameters
244
+ header_params = opts[:header_params] || {}
245
+ # HTTP header 'Accept' (if needed)
246
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
247
+
248
+ # form parameters
249
+ form_params = opts[:form_params] || {}
250
+
251
+ # http body (model)
252
+ post_body = opts[:debug_body]
253
+
254
+ # return_type
255
+ return_type = opts[:debug_return_type] || 'Product'
256
+
257
+ # auth_names
258
+ auth_names = opts[:debug_auth_names] || ['apiKey']
259
+
260
+ new_options = opts.merge(
261
+ :operation => :"ProductsApi.get_product",
262
+ :header_params => header_params,
263
+ :query_params => query_params,
264
+ :form_params => form_params,
265
+ :body => post_body,
266
+ :auth_names => auth_names,
267
+ :return_type => return_type
268
+ )
269
+
270
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
271
+ if @api_client.config.debugging
272
+ @api_client.config.logger.debug "API called: ProductsApi#get_product\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
273
+ end
274
+ return data, status_code, headers
275
+ end
276
+
277
+ # Get the stats of a product
278
+ # Counts of the licenses and machines of the product, number of licenses created each day over the last 30 days and each month over the last 12 months, overall and per policy, revenue per currency over the same periods, and successful activations each day over the last 30 days. Days and months are in UTC.
279
+ # @param id [String]
280
+ # @param [Hash] opts the optional parameters
281
+ # @return [ProductStats]
282
+ def get_product_stats(id, opts = {})
283
+ data, _status_code, _headers = get_product_stats_with_http_info(id, opts)
284
+ data
285
+ end
286
+
287
+ # Get the stats of a product
288
+ # Counts of the licenses and machines of the product, number of licenses created each day over the last 30 days and each month over the last 12 months, overall and per policy, revenue per currency over the same periods, and successful activations each day over the last 30 days. Days and months are in UTC.
289
+ # @param id [String]
290
+ # @param [Hash] opts the optional parameters
291
+ # @return [Array<(ProductStats, Integer, Hash)>] ProductStats data, response status code and response headers
292
+ def get_product_stats_with_http_info(id, opts = {})
293
+ if @api_client.config.debugging
294
+ @api_client.config.logger.debug 'Calling API: ProductsApi.get_product_stats ...'
295
+ end
296
+ # verify the required parameter 'id' is set
297
+ if @api_client.config.client_side_validation && id.nil?
298
+ fail ArgumentError, "Missing the required parameter 'id' when calling ProductsApi.get_product_stats"
299
+ end
300
+ # resource path
301
+ local_var_path = '/v1/products/{id}/stats'.sub('{id}', CGI.escape(id.to_s))
302
+
303
+ # query parameters
304
+ query_params = opts[:query_params] || {}
305
+
306
+ # header parameters
307
+ header_params = opts[:header_params] || {}
308
+ # HTTP header 'Accept' (if needed)
309
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
310
+
311
+ # form parameters
312
+ form_params = opts[:form_params] || {}
313
+
314
+ # http body (model)
315
+ post_body = opts[:debug_body]
316
+
317
+ # return_type
318
+ return_type = opts[:debug_return_type] || 'ProductStats'
319
+
320
+ # auth_names
321
+ auth_names = opts[:debug_auth_names] || ['apiKey']
322
+
323
+ new_options = opts.merge(
324
+ :operation => :"ProductsApi.get_product_stats",
325
+ :header_params => header_params,
326
+ :query_params => query_params,
327
+ :form_params => form_params,
328
+ :body => post_body,
329
+ :auth_names => auth_names,
330
+ :return_type => return_type
331
+ )
332
+
333
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
334
+ if @api_client.config.debugging
335
+ @api_client.config.logger.debug "API called: ProductsApi#get_product_stats\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
336
+ end
337
+ return data, status_code, headers
338
+ end
339
+
340
+ # List products
341
+ # @param [Hash] opts the optional parameters
342
+ # @option opts [Integer] :page Page to return. Pages are numbered from 1: &#x60;1&#x60; is the first page. A page past the last one returns an empty &#x60;data&#x60;, not an error. Defaults to &#x60;1&#x60;. (default to 1)
343
+ # @option opts [Integer] :page_size Maximum number of items per page, from 1 to 100. Every page holds this many items except the last one, which can hold fewer. Defaults to &#x60;20&#x60;. (default to 20)
344
+ # @option opts [String] :sort Field to sort by, prefixed with &#x60;-&#x60; for descending order. Defaults to &#x60;-createdAt&#x60;. (default to '-createdAt')
345
+ # @option opts [String] :search Case-insensitive text the name or slug contains.
346
+ # @option opts [String] :slug Only returns the product with this exact slug.
347
+ # @option opts [String] :is_test Only returns the test products with &#x60;true&#x60;, the live ones with &#x60;false&#x60;. API keys only list the products of their own mode.
348
+ # @return [ProductList]
349
+ def list_products(opts = {})
350
+ data, _status_code, _headers = list_products_with_http_info(opts)
351
+ data
352
+ end
353
+
354
+ # List products
355
+ # @param [Hash] opts the optional parameters
356
+ # @option opts [Integer] :page Page to return. Pages are numbered from 1: &#x60;1&#x60; is the first page. A page past the last one returns an empty &#x60;data&#x60;, not an error. Defaults to &#x60;1&#x60;. (default to 1)
357
+ # @option opts [Integer] :page_size Maximum number of items per page, from 1 to 100. Every page holds this many items except the last one, which can hold fewer. Defaults to &#x60;20&#x60;. (default to 20)
358
+ # @option opts [String] :sort Field to sort by, prefixed with &#x60;-&#x60; for descending order. Defaults to &#x60;-createdAt&#x60;. (default to '-createdAt')
359
+ # @option opts [String] :search Case-insensitive text the name or slug contains.
360
+ # @option opts [String] :slug Only returns the product with this exact slug.
361
+ # @option opts [String] :is_test Only returns the test products with &#x60;true&#x60;, the live ones with &#x60;false&#x60;. API keys only list the products of their own mode.
362
+ # @return [Array<(ProductList, Integer, Hash)>] ProductList data, response status code and response headers
363
+ def list_products_with_http_info(opts = {})
364
+ if @api_client.config.debugging
365
+ @api_client.config.logger.debug 'Calling API: ProductsApi.list_products ...'
366
+ end
367
+ if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
368
+ fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ProductsApi.list_products, must be greater than or equal to 1.'
369
+ end
370
+
371
+ if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
372
+ fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ProductsApi.list_products, must be smaller than or equal to 100.'
373
+ end
374
+
375
+ if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
376
+ fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ProductsApi.list_products, must be greater than or equal to 1.'
377
+ end
378
+
379
+ allowable_values = ["name", "-name", "slug", "-slug", "createdAt", "-createdAt", "updatedAt", "-updatedAt", "unknown_default_open_api"]
380
+ if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
381
+ fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
382
+ end
383
+ if @api_client.config.client_side_validation && !opts[:'search'].nil? && opts[:'search'].to_s.length > 200
384
+ fail ArgumentError, 'invalid value for "opts[:"search"]" when calling ProductsApi.list_products, the character length must be smaller than or equal to 200.'
385
+ end
386
+
387
+ if @api_client.config.client_side_validation && !opts[:'search'].nil? && opts[:'search'].to_s.length < 1
388
+ fail ArgumentError, 'invalid value for "opts[:"search"]" when calling ProductsApi.list_products, the character length must be greater than or equal to 1.'
389
+ end
390
+
391
+ allowable_values = ["true", "false", "unknown_default_open_api"]
392
+ if @api_client.config.client_side_validation && opts[:'is_test'] && !allowable_values.include?(opts[:'is_test'])
393
+ fail ArgumentError, "invalid value for \"is_test\", must be one of #{allowable_values}"
394
+ end
395
+ # resource path
396
+ local_var_path = '/v1/products'
397
+
398
+ # query parameters
399
+ query_params = opts[:query_params] || {}
400
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
401
+ query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].nil?
402
+ query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
403
+ query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?
404
+ query_params[:'slug'] = opts[:'slug'] if !opts[:'slug'].nil?
405
+ query_params[:'isTest'] = opts[:'is_test'] if !opts[:'is_test'].nil?
406
+
407
+ # header parameters
408
+ header_params = opts[:header_params] || {}
409
+ # HTTP header 'Accept' (if needed)
410
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
411
+
412
+ # form parameters
413
+ form_params = opts[:form_params] || {}
414
+
415
+ # http body (model)
416
+ post_body = opts[:debug_body]
417
+
418
+ # return_type
419
+ return_type = opts[:debug_return_type] || 'ProductList'
420
+
421
+ # auth_names
422
+ auth_names = opts[:debug_auth_names] || ['apiKey']
423
+
424
+ new_options = opts.merge(
425
+ :operation => :"ProductsApi.list_products",
426
+ :header_params => header_params,
427
+ :query_params => query_params,
428
+ :form_params => form_params,
429
+ :body => post_body,
430
+ :auth_names => auth_names,
431
+ :return_type => return_type
432
+ )
433
+
434
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
435
+ if @api_client.config.debugging
436
+ @api_client.config.logger.debug "API called: ProductsApi#list_products\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
437
+ end
438
+ return data, status_code, headers
439
+ end
440
+
441
+ # Reset a test product
442
+ # Deletes the customers, licenses, machines, policies and releases of the test product, with their events, then copies the policies, releases and portal settings of its live product again. Its id, name and slug are kept, but the copied policies get new ids. The tokens of its customers, licenses and machines stop working. **Required role permission**: `product:update` when called with a session, granted by the member's role. API keys aren't limited by roles.
443
+ # @param id [String]
444
+ # @param [Hash] opts the optional parameters
445
+ # @return [Product]
446
+ def reset_product(id, opts = {})
447
+ data, _status_code, _headers = reset_product_with_http_info(id, opts)
448
+ data
449
+ end
450
+
451
+ # Reset a test product
452
+ # Deletes the customers, licenses, machines, policies and releases of the test product, with their events, then copies the policies, releases and portal settings of its live product again. Its id, name and slug are kept, but the copied policies get new ids. The tokens of its customers, licenses and machines stop working. **Required role permission**: &#x60;product:update&#x60; when called with a session, granted by the member&#39;s role. API keys aren&#39;t limited by roles.
453
+ # @param id [String]
454
+ # @param [Hash] opts the optional parameters
455
+ # @return [Array<(Product, Integer, Hash)>] Product data, response status code and response headers
456
+ def reset_product_with_http_info(id, opts = {})
457
+ if @api_client.config.debugging
458
+ @api_client.config.logger.debug 'Calling API: ProductsApi.reset_product ...'
459
+ end
460
+ # verify the required parameter 'id' is set
461
+ if @api_client.config.client_side_validation && id.nil?
462
+ fail ArgumentError, "Missing the required parameter 'id' when calling ProductsApi.reset_product"
463
+ end
464
+ # resource path
465
+ local_var_path = '/v1/products/{id}/reset'.sub('{id}', CGI.escape(id.to_s))
466
+
467
+ # query parameters
468
+ query_params = opts[:query_params] || {}
469
+
470
+ # header parameters
471
+ header_params = opts[:header_params] || {}
472
+ # HTTP header 'Accept' (if needed)
473
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
474
+
475
+ # form parameters
476
+ form_params = opts[:form_params] || {}
477
+
478
+ # http body (model)
479
+ post_body = opts[:debug_body]
480
+
481
+ # return_type
482
+ return_type = opts[:debug_return_type] || 'Product'
483
+
484
+ # auth_names
485
+ auth_names = opts[:debug_auth_names] || ['apiKey']
486
+
487
+ new_options = opts.merge(
488
+ :operation => :"ProductsApi.reset_product",
489
+ :header_params => header_params,
490
+ :query_params => query_params,
491
+ :form_params => form_params,
492
+ :body => post_body,
493
+ :auth_names => auth_names,
494
+ :return_type => return_type
495
+ )
496
+
497
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
498
+ if @api_client.config.debugging
499
+ @api_client.config.logger.debug "API called: ProductsApi#reset_product\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
500
+ end
501
+ return data, status_code, headers
502
+ end
503
+
504
+ # Update a product
505
+ # A product can't be turned into a test product, or back: `isTestFromProductId` can't be changed. **Required role permission**: `product:update` when called with a session, granted by the member's role. API keys aren't limited by roles.
506
+ # @param id [String]
507
+ # @param update_product [UpdateProduct]
508
+ # @param [Hash] opts the optional parameters
509
+ # @return [Product]
510
+ def update_product(id, update_product, opts = {})
511
+ data, _status_code, _headers = update_product_with_http_info(id, update_product, opts)
512
+ data
513
+ end
514
+
515
+ # Update a product
516
+ # A product can&#39;t be turned into a test product, or back: &#x60;isTestFromProductId&#x60; can&#39;t be changed. **Required role permission**: &#x60;product:update&#x60; when called with a session, granted by the member&#39;s role. API keys aren&#39;t limited by roles.
517
+ # @param id [String]
518
+ # @param update_product [UpdateProduct]
519
+ # @param [Hash] opts the optional parameters
520
+ # @return [Array<(Product, Integer, Hash)>] Product data, response status code and response headers
521
+ def update_product_with_http_info(id, update_product, opts = {})
522
+ if @api_client.config.debugging
523
+ @api_client.config.logger.debug 'Calling API: ProductsApi.update_product ...'
524
+ end
525
+ # verify the required parameter 'id' is set
526
+ if @api_client.config.client_side_validation && id.nil?
527
+ fail ArgumentError, "Missing the required parameter 'id' when calling ProductsApi.update_product"
528
+ end
529
+ # verify the required parameter 'update_product' is set
530
+ if @api_client.config.client_side_validation && update_product.nil?
531
+ fail ArgumentError, "Missing the required parameter 'update_product' when calling ProductsApi.update_product"
532
+ end
533
+ # resource path
534
+ local_var_path = '/v1/products/{id}'.sub('{id}', CGI.escape(id.to_s))
535
+
536
+ # query parameters
537
+ query_params = opts[:query_params] || {}
538
+
539
+ # header parameters
540
+ header_params = opts[:header_params] || {}
541
+ # HTTP header 'Accept' (if needed)
542
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
543
+ # HTTP header 'Content-Type'
544
+ content_type = @api_client.select_header_content_type(['application/json'])
545
+ if !content_type.nil?
546
+ header_params['Content-Type'] = content_type
547
+ end
548
+
549
+ # form parameters
550
+ form_params = opts[:form_params] || {}
551
+
552
+ # http body (model)
553
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(update_product)
554
+
555
+ # return_type
556
+ return_type = opts[:debug_return_type] || 'Product'
557
+
558
+ # auth_names
559
+ auth_names = opts[:debug_auth_names] || ['apiKey']
560
+
561
+ new_options = opts.merge(
562
+ :operation => :"ProductsApi.update_product",
563
+ :header_params => header_params,
564
+ :query_params => query_params,
565
+ :form_params => form_params,
566
+ :body => post_body,
567
+ :auth_names => auth_names,
568
+ :return_type => return_type
569
+ )
570
+
571
+ data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
572
+ if @api_client.config.debugging
573
+ @api_client.config.logger.debug "API called: ProductsApi#update_product\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
574
+ end
575
+ return data, status_code, headers
576
+ end
577
+
578
+ # Upload a product logo
579
+ # Replaces the logo of the product, shown in the web app and the customer portal. The previous logo is deleted. Accepts WebP, PNG, JPEG and SVG images up to 1 MB, recognized by their content. Logos are shown in squares: use square images, 256×256 pixels for bitmaps. The web app crops and resizes images to this size, and converts them to WebP, before uploading them. **Required role permission**: `product:update` when called with a session, granted by the member's role. API keys aren't limited by roles.
580
+ # @param id [String]
581
+ # @param file [File] WebP, PNG, JPEG or SVG image, up to 1 MB.
582
+ # @param [Hash] opts the optional parameters
583
+ # @return [Product]
584
+ def upload_product_logo(id, file, opts = {})
585
+ data, _status_code, _headers = upload_product_logo_with_http_info(id, file, opts)
586
+ data
587
+ end
588
+
589
+ # Upload a product logo
590
+ # Replaces the logo of the product, shown in the web app and the customer portal. The previous logo is deleted. Accepts WebP, PNG, JPEG and SVG images up to 1 MB, recognized by their content. Logos are shown in squares: use square images, 256×256 pixels for bitmaps. The web app crops and resizes images to this size, and converts them to WebP, before uploading them. **Required role permission**: &#x60;product:update&#x60; when called with a session, granted by the member&#39;s role. API keys aren&#39;t limited by roles.
591
+ # @param id [String]
592
+ # @param file [File] WebP, PNG, JPEG or SVG image, up to 1 MB.
593
+ # @param [Hash] opts the optional parameters
594
+ # @return [Array<(Product, Integer, Hash)>] Product data, response status code and response headers
595
+ def upload_product_logo_with_http_info(id, file, opts = {})
596
+ if @api_client.config.debugging
597
+ @api_client.config.logger.debug 'Calling API: ProductsApi.upload_product_logo ...'
598
+ end
599
+ # verify the required parameter 'id' is set
600
+ if @api_client.config.client_side_validation && id.nil?
601
+ fail ArgumentError, "Missing the required parameter 'id' when calling ProductsApi.upload_product_logo"
602
+ end
603
+ # verify the required parameter 'file' is set
604
+ if @api_client.config.client_side_validation && file.nil?
605
+ fail ArgumentError, "Missing the required parameter 'file' when calling ProductsApi.upload_product_logo"
606
+ end
607
+ # resource path
608
+ local_var_path = '/v1/products/{id}/logo'.sub('{id}', CGI.escape(id.to_s))
609
+
610
+ # query parameters
611
+ query_params = opts[:query_params] || {}
612
+
613
+ # header parameters
614
+ header_params = opts[:header_params] || {}
615
+ # HTTP header 'Accept' (if needed)
616
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
617
+ # HTTP header 'Content-Type'
618
+ content_type = @api_client.select_header_content_type(['multipart/form-data'])
619
+ if !content_type.nil?
620
+ header_params['Content-Type'] = content_type
621
+ end
622
+
623
+ # form parameters
624
+ form_params = opts[:form_params] || {}
625
+ form_params['file'] = file
626
+
627
+ # http body (model)
628
+ post_body = opts[:debug_body]
629
+
630
+ # return_type
631
+ return_type = opts[:debug_return_type] || 'Product'
632
+
633
+ # auth_names
634
+ auth_names = opts[:debug_auth_names] || ['apiKey']
635
+
636
+ new_options = opts.merge(
637
+ :operation => :"ProductsApi.upload_product_logo",
638
+ :header_params => header_params,
639
+ :query_params => query_params,
640
+ :form_params => form_params,
641
+ :body => post_body,
642
+ :auth_names => auth_names,
643
+ :return_type => return_type
644
+ )
645
+
646
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
647
+ if @api_client.config.debugging
648
+ @api_client.config.logger.debug "API called: ProductsApi#upload_product_logo\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
649
+ end
650
+ return data, status_code, headers
651
+ end
652
+ end
653
+ end