From 81ea4d78f9602b4779a47ffe3891c3cd26b24686 Mon Sep 17 00:00:00 2001 From: Lucas Mazza Date: Mon, 5 Aug 2024 17:01:24 -0300 Subject: [PATCH] Regenerate client for `5.3.0` * Add support for `public_key` endpoints * Add support for `list_roles` endpoint, and use the new role ids on organization member responses * Add support for `delete_webhook`, that was missing from the spec * Add support for copying `custom_roles` when creating a new organization --- .openapi-generator/FILES | 11 + Gemfile.lock | 2 +- lib/tremendous.rb | 11 + lib/tremendous/api/tremendous_api.rb | 473 +++++++++++++++++- lib/tremendous/models/create_member.rb | 36 +- .../models/create_member_request.rb | 36 +- ...eate_organization_request_copy_settings.rb | 16 +- lib/tremendous/models/create_public_key.rb | 222 ++++++++ .../models/create_public_key200_response.rb | 221 ++++++++ .../models/create_public_key_request.rb | 222 ++++++++ .../models/get_member200_response_member.rb | 22 +- .../list_members200_response_members_inner.rb | 22 +- .../models/list_roles200_response.rb | 223 +++++++++ .../list_roles200_response_roles_inner.rb | 275 ++++++++++ lib/tremendous/models/member.rb | 22 +- lib/tremendous/models/member_base.rb | 22 +- lib/tremendous/models/member_with_events.rb | 22 +- .../models/member_without_events.rb | 22 +- lib/tremendous/models/public_key.rb | 257 ++++++++++ lib/tremendous/models/public_keys_response.rb | 223 +++++++++ .../public_keys_response_public_keys_inner.rb | 257 ++++++++++ lib/tremendous/models/role.rb | 275 ++++++++++ lib/tremendous/models/test_public_key.rb | 222 ++++++++ .../models/test_public_key_request.rb | 222 ++++++++ lib/tremendous/version.rb | 2 +- 25 files changed, 3140 insertions(+), 198 deletions(-) create mode 100644 lib/tremendous/models/create_public_key.rb create mode 100644 lib/tremendous/models/create_public_key200_response.rb create mode 100644 lib/tremendous/models/create_public_key_request.rb create mode 100644 lib/tremendous/models/list_roles200_response.rb create mode 100644 lib/tremendous/models/list_roles200_response_roles_inner.rb create mode 100644 lib/tremendous/models/public_key.rb create mode 100644 lib/tremendous/models/public_keys_response.rb create mode 100644 lib/tremendous/models/public_keys_response_public_keys_inner.rb create mode 100644 lib/tremendous/models/role.rb create mode 100644 lib/tremendous/models/test_public_key.rb create mode 100644 lib/tremendous/models/test_public_key_request.rb diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 9c1877d..cdbfce5 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -30,6 +30,9 @@ lib/tremendous/models/create_organization200_response.rb lib/tremendous/models/create_organization200_response_organization.rb lib/tremendous/models/create_organization_request.rb lib/tremendous/models/create_organization_request_copy_settings.rb +lib/tremendous/models/create_public_key.rb +lib/tremendous/models/create_public_key200_response.rb +lib/tremendous/models/create_public_key_request.rb lib/tremendous/models/create_webhook200_response.rb lib/tremendous/models/create_webhook_request.rb lib/tremendous/models/currency_codes.rb @@ -90,6 +93,8 @@ lib/tremendous/models/list_rewards200_response_rewards_inner_value.rb lib/tremendous/models/list_rewards401_response.rb lib/tremendous/models/list_rewards401_response_errors.rb lib/tremendous/models/list_rewards429_response.rb +lib/tremendous/models/list_roles200_response.rb +lib/tremendous/models/list_roles200_response_roles_inner.rb lib/tremendous/models/list_webhook_events200_response.rb lib/tremendous/models/list_webhooks200_response.rb lib/tremendous/models/list_webhooks200_response_webhooks_inner.rb @@ -111,6 +116,9 @@ lib/tremendous/models/organization.rb lib/tremendous/models/payment_details.rb lib/tremendous/models/payment_details_refund.rb lib/tremendous/models/product.rb +lib/tremendous/models/public_key.rb +lib/tremendous/models/public_keys_response.rb +lib/tremendous/models/public_keys_response_public_keys_inner.rb lib/tremendous/models/recipient.rb lib/tremendous/models/refund_details.rb lib/tremendous/models/resend_reward422_response.rb @@ -125,7 +133,10 @@ lib/tremendous/models/reward_with_link.rb lib/tremendous/models/reward_with_link_delivery.rb lib/tremendous/models/reward_without_link.rb lib/tremendous/models/reward_without_link_delivery.rb +lib/tremendous/models/role.rb lib/tremendous/models/simulate_webhook_request.rb +lib/tremendous/models/test_public_key.rb +lib/tremendous/models/test_public_key_request.rb lib/tremendous/models/update_campaign.rb lib/tremendous/models/update_campaign_request.rb lib/tremendous/models/webhook.rb diff --git a/Gemfile.lock b/Gemfile.lock index 9ee6360..f36d65a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tremendous_ruby (5.2.0) + tremendous_ruby (5.3.0) faraday (>= 1.0.1, < 3.0) faraday-multipart diff --git a/lib/tremendous.rb b/lib/tremendous.rb index 1d68c4a..c8dadf0 100644 --- a/lib/tremendous.rb +++ b/lib/tremendous.rb @@ -44,6 +44,9 @@ require 'tremendous/models/create_organization200_response_organization' require 'tremendous/models/create_organization_request' require 'tremendous/models/create_organization_request_copy_settings' +require 'tremendous/models/create_public_key' +require 'tremendous/models/create_public_key200_response' +require 'tremendous/models/create_public_key_request' require 'tremendous/models/create_webhook200_response' require 'tremendous/models/create_webhook_request' require 'tremendous/models/currency_codes' @@ -104,6 +107,8 @@ require 'tremendous/models/list_rewards401_response' require 'tremendous/models/list_rewards401_response_errors' require 'tremendous/models/list_rewards429_response' +require 'tremendous/models/list_roles200_response' +require 'tremendous/models/list_roles200_response_roles_inner' require 'tremendous/models/list_webhook_events200_response' require 'tremendous/models/list_webhooks200_response' require 'tremendous/models/list_webhooks200_response_webhooks_inner' @@ -125,6 +130,9 @@ require 'tremendous/models/payment_details' require 'tremendous/models/payment_details_refund' require 'tremendous/models/product' +require 'tremendous/models/public_key' +require 'tremendous/models/public_keys_response' +require 'tremendous/models/public_keys_response_public_keys_inner' require 'tremendous/models/recipient' require 'tremendous/models/refund_details' require 'tremendous/models/resend_reward422_response' @@ -139,7 +147,10 @@ require 'tremendous/models/reward_with_link_delivery' require 'tremendous/models/reward_without_link' require 'tremendous/models/reward_without_link_delivery' +require 'tremendous/models/role' require 'tremendous/models/simulate_webhook_request' +require 'tremendous/models/test_public_key' +require 'tremendous/models/test_public_key_request' require 'tremendous/models/update_campaign' require 'tremendous/models/update_campaign_request' require 'tremendous/models/webhook' diff --git a/lib/tremendous/api/tremendous_api.rb b/lib/tremendous/api/tremendous_api.rb index 93e0bc7..834a529 100644 --- a/lib/tremendous/api/tremendous_api.rb +++ b/lib/tremendous/api/tremendous_api.rb @@ -279,7 +279,7 @@ def create_invoice_with_http_info(create_invoice_request, opts = {}) end # Create member - # Each organization has one or more users that can access and manage that organization. These users are called members. Members can take actions via the Tremendous web dashboard directly. These actions include adding funding sources to the organization, creating Campaigns, and more. ### Permissions Members can have one of two roles that determine their permissions within the organization: 1. `MEMBER`: Limited permissions. Can view their own reward and order histories only. 2. `ADMIN`: Update organization settings, invite other members to the organization, and view all member order and reward histories within their organization. To create members of a sub-organizations [create an API key for that organization](/reference/post_organizations-id-create-api-key) first, then use the new API key in the create member request. ### Inviting new members After creating a member, an automatic invite is sent to the email address. If the user is not registered yet, that person will then need to sign up for a Tremendous account. > ❗️ Automatic invitations are not available in the sandbox > > You must manually use the returned `invite_url` field in the payload instead. + # Each organization has one or more users that can access and manage that organization. These users are called members. Members can take actions via the Tremendous web dashboard directly. These actions include adding funding sources to the organization, creating Campaigns, and more. ### Permissions Members can have a role that determine their permissions within the organization. Check the Roles API for the available roles. To create members of a sub-organizations [create an API key for that organization](/reference/post_organizations-id-create-api-key) first, then use the new API key in the create member request. ### Inviting new members After creating a member, an automatic invite is sent to the email address. If the user is not registered yet, that person will then need to sign up for a Tremendous account. > ❗️ Automatic invitations are not available in the sandbox > > You must manually use the returned `invite_url` field in the payload instead. # @param create_member_request [CreateMemberRequest] Member details # @param [Hash] opts the optional parameters # @return [CreateMember200Response] @@ -289,7 +289,7 @@ def create_member(create_member_request, opts = {}) end # Create member - # Each organization has one or more users that can access and manage that organization. These users are called members. Members can take actions via the Tremendous web dashboard directly. These actions include adding funding sources to the organization, creating Campaigns, and more. ### Permissions Members can have one of two roles that determine their permissions within the organization: 1. `MEMBER`: Limited permissions. Can view their own reward and order histories only. 2. `ADMIN`: Update organization settings, invite other members to the organization, and view all member order and reward histories within their organization. To create members of a sub-organizations [create an API key for that organization](/reference/post_organizations-id-create-api-key) first, then use the new API key in the create member request. ### Inviting new members After creating a member, an automatic invite is sent to the email address. If the user is not registered yet, that person will then need to sign up for a Tremendous account. > ❗️ Automatic invitations are not available in the sandbox > > You must manually use the returned `invite_url` field in the payload instead. + # Each organization has one or more users that can access and manage that organization. These users are called members. Members can take actions via the Tremendous web dashboard directly. These actions include adding funding sources to the organization, creating Campaigns, and more. ### Permissions Members can have a role that determine their permissions within the organization. Check the Roles API for the available roles. To create members of a sub-organizations [create an API key for that organization](/reference/post_organizations-id-create-api-key) first, then use the new API key in the create member request. ### Inviting new members After creating a member, an automatic invite is sent to the email address. If the user is not registered yet, that person will then need to sign up for a Tremendous account. > ❗️ Automatic invitations are not available in the sandbox > > You must manually use the returned `invite_url` field in the payload instead. # @param create_member_request [CreateMemberRequest] Member details # @param [Hash] opts the optional parameters # @return [Array<(CreateMember200Response, Integer, Hash)>] CreateMember200Response data, response status code and response headers @@ -482,6 +482,74 @@ def create_organization_with_http_info(create_organization_request, opts = {}) return data, status_code, headers end + # Create public key + # Creating a public key is the way for your organization to share it with Tremendous. > 🔒 Generating asymmetric keys > > **We recommend using [OpenSSL](https://www.openssl.org/).** > > 1. Generate a private key and a public key in PEM: > `openssl genrsa -out tremendous_key.pem 4096` > > 2. Extract the public key in PEM format: > `openssl rsa -in tremendous_key.pem -outform PEM -pubout -out tremendous_key.pem.pub` > > 3. And, before making your request, encode it as a `base64` string: > `base64 -i tremendous_key.pem.pub`
Property Type Description
public_key
string

Base64 encoded (public) PEM file

+ # @param create_public_key_request [CreatePublicKeyRequest] Public key details + # @param [Hash] opts the optional parameters + # @return [CreatePublicKey200Response] + def create_public_key(create_public_key_request, opts = {}) + data, _status_code, _headers = create_public_key_with_http_info(create_public_key_request, opts) + data + end + + # Create public key + # Creating a public key is the way for your organization to share it with Tremendous. > 🔒 Generating asymmetric keys > > **We recommend using [OpenSSL](https://www.openssl.org/).** > > 1. Generate a private key and a public key in PEM: > `openssl genrsa -out tremendous_key.pem 4096` > > 2. Extract the public key in PEM format: > `openssl rsa -in tremendous_key.pem -outform PEM -pubout -out tremendous_key.pem.pub` > > 3. And, before making your request, encode it as a `base64` string: > `base64 -i tremendous_key.pem.pub` <div class=\"object-schema-request-schema\"> <table> <thead> <tr> <th>Property</th> <th>Type</th> <th>Description</th> </tr> </thead> <tbody class=\"object-schema-table-body\"> <tr class=\"\"><td><div class=\"property-name\"> <code class=\"property-name\">public_key</code> </div> </td><td><span class=\"property-type\">string</span></td><td><p>Base64 encoded (public) PEM file</p> </td></tr> </tbody> </table> </div> + # @param create_public_key_request [CreatePublicKeyRequest] Public key details + # @param [Hash] opts the optional parameters + # @return [Array<(CreatePublicKey200Response, Integer, Hash)>] CreatePublicKey200Response data, response status code and response headers + def create_public_key_with_http_info(create_public_key_request, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TremendousApi.create_public_key ...' + end + # verify the required parameter 'create_public_key_request' is set + if @api_client.config.client_side_validation && create_public_key_request.nil? + fail ArgumentError, "Missing the required parameter 'create_public_key_request' when calling TremendousApi.create_public_key" + end + # resource path + local_var_path = '/public_keys' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(create_public_key_request) + + # return_type + return_type = opts[:debug_return_type] || 'CreatePublicKey200Response' + + # auth_names + auth_names = opts[:debug_auth_names] || ['BearerApiKey'] + + new_options = opts.merge( + :operation => :"TremendousApi.create_public_key", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TremendousApi#create_public_key\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Create webhook # Tremendous uses webhooks as a notification system for various events that happen in your account. > 📘 Learn more about Webhooks > > Our guide explains everything you need to know about the Tremendous webhooks: > [Read it here](/docs/webhooks-1) Every organization can define a single webhook endpoint where we send requests to, whenever an event happens. This endpoint allows you to setup that endpoint. The URL of the endpoint can be changed by making a request to this endpoint again with the new URL. ## Request body
Property Type Description
url
string uri

URL the webhook will make requests to

# @param create_webhook_request [CreateWebhookRequest] Webhook details @@ -552,7 +620,7 @@ def create_webhook_with_http_info(create_webhook_request, opts = {}) # Delete invoice # Removes an invoice. This has no further consequences but is a rather cosmetic operation. - # @param id [String] ID of the invoice that should be retrieved + # @param id [String] ID of the invoice that should be removed # @param [Hash] opts the optional parameters # @return [CreateInvoice200Response] def delete_invoices(id, opts = {}) @@ -562,7 +630,7 @@ def delete_invoices(id, opts = {}) # Delete invoice # Removes an invoice. This has no further consequences but is a rather cosmetic operation. - # @param id [String] ID of the invoice that should be retrieved + # @param id [String] ID of the invoice that should be removed # @param [Hash] opts the optional parameters # @return [Array<(CreateInvoice200Response, Integer, Hash)>] CreateInvoice200Response data, response status code and response headers def delete_invoices_with_http_info(id, opts = {}) @@ -613,6 +681,142 @@ def delete_invoices_with_http_info(id, opts = {}) return data, status_code, headers end + # Delete public key + # Deactivates a public key. Any further attempt to verify a request signature with this key will fail. + # @param id [String] ID of the public key that should be deactivated + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_public_key(id, opts = {}) + delete_public_key_with_http_info(id, opts) + nil + end + + # Delete public key + # Deactivates a public key. Any further attempt to verify a request signature with this key will fail. + # @param id [String] ID of the public key that should be deactivated + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_public_key_with_http_info(id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TremendousApi.delete_public_key ...' + end + # verify the required parameter 'id' is set + if @api_client.config.client_side_validation && id.nil? + fail ArgumentError, "Missing the required parameter 'id' when calling TremendousApi.delete_public_key" + end + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if @api_client.config.client_side_validation && id !~ pattern + fail ArgumentError, "invalid value for 'id' when calling TremendousApi.delete_public_key, must conform to the pattern #{pattern}." + end + + # resource path + local_var_path = '/public_keys/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['BearerApiKey'] + + new_options = opts.merge( + :operation => :"TremendousApi.delete_public_key", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TremendousApi#delete_public_key\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete webhook + # > 📘 Learn more about Webhooks > > Our guide explains everything you need to know about the Tremendous webhooks: > [Read it here](/docs/webhooks-1) + # @param id [String] ID of the webhook to delete + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_webhook(id, opts = {}) + delete_webhook_with_http_info(id, opts) + nil + end + + # Delete webhook + # > 📘 Learn more about Webhooks > > Our guide explains everything you need to know about the Tremendous webhooks: > [Read it here](/docs/webhooks-1) + # @param id [String] ID of the webhook to delete + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_webhook_with_http_info(id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TremendousApi.delete_webhook ...' + end + # verify the required parameter 'id' is set + if @api_client.config.client_side_validation && id.nil? + fail ArgumentError, "Missing the required parameter 'id' when calling TremendousApi.delete_webhook" + end + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if @api_client.config.client_side_validation && id !~ pattern + fail ArgumentError, "invalid value for 'id' when calling TremendousApi.delete_webhook, must conform to the pattern #{pattern}." + end + + # resource path + local_var_path = '/webhooks/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['BearerApiKey'] + + new_options = opts.merge( + :operation => :"TremendousApi.delete_webhook", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TremendousApi#delete_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Retrieve invoice as CSV # Generates a CSV version for an invoice listing the associated rewards and orders # @param id [String] ID of the Invoice for that the CSV should be generated @@ -1337,6 +1541,74 @@ def get_product_with_http_info(id, opts = {}) return data, status_code, headers end + # Retrieve public key + # Retrieve an active public key, identified by the given `id` in the URL. + # @param id [String] ID of the public key that should be retrieved + # @param [Hash] opts the optional parameters + # @return [CreatePublicKey200Response] + def get_public_key(id, opts = {}) + data, _status_code, _headers = get_public_key_with_http_info(id, opts) + data + end + + # Retrieve public key + # Retrieve an active public key, identified by the given `id` in the URL. + # @param id [String] ID of the public key that should be retrieved + # @param [Hash] opts the optional parameters + # @return [Array<(CreatePublicKey200Response, Integer, Hash)>] CreatePublicKey200Response data, response status code and response headers + def get_public_key_with_http_info(id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TremendousApi.get_public_key ...' + end + # verify the required parameter 'id' is set + if @api_client.config.client_side_validation && id.nil? + fail ArgumentError, "Missing the required parameter 'id' when calling TremendousApi.get_public_key" + end + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if @api_client.config.client_side_validation && id !~ pattern + fail ArgumentError, "invalid value for 'id' when calling TremendousApi.get_public_key, must conform to the pattern #{pattern}." + end + + # resource path + local_var_path = '/public_keys/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CreatePublicKey200Response' + + # auth_names + auth_names = opts[:debug_auth_names] || ['BearerApiKey'] + + new_options = opts.merge( + :operation => :"TremendousApi.get_public_key", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TremendousApi#get_public_key\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Retrieve single reward # Retrieve the reward, identified by the given `id` in the URL # @param id [String] ID of the reward that should be retrieved @@ -2088,6 +2360,63 @@ def list_products_with_http_info(opts = {}) return data, status_code, headers end + # List public keys + # Fetch a list of active public keys on your account. > 🚧 Inactive public keys are omitted > > The response does not include inactive public keys. + # @param [Hash] opts the optional parameters + # @return [PublicKeysResponse] + def list_public_keys(opts = {}) + data, _status_code, _headers = list_public_keys_with_http_info(opts) + data + end + + # List public keys + # Fetch a list of active public keys on your account. > 🚧 Inactive public keys are omitted > > The response does not include inactive public keys. + # @param [Hash] opts the optional parameters + # @return [Array<(PublicKeysResponse, Integer, Hash)>] PublicKeysResponse data, response status code and response headers + def list_public_keys_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TremendousApi.list_public_keys ...' + end + # resource path + local_var_path = '/public_keys' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'PublicKeysResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['BearerApiKey'] + + new_options = opts.merge( + :operation => :"TremendousApi.list_public_keys", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TremendousApi#list_public_keys\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # List rewards # Retrieve a list of all created rewards # @param [Hash] opts the optional parameters @@ -2148,6 +2477,63 @@ def list_rewards_with_http_info(opts = {}) return data, status_code, headers end + # List roles + # List all available roles in the organization. + # @param [Hash] opts the optional parameters + # @return [ListRoles200Response] + def list_roles(opts = {}) + data, _status_code, _headers = list_roles_with_http_info(opts) + data + end + + # List roles + # List all available roles in the organization. + # @param [Hash] opts the optional parameters + # @return [Array<(ListRoles200Response, Integer, Hash)>] ListRoles200Response data, response status code and response headers + def list_roles_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TremendousApi.list_roles ...' + end + # resource path + local_var_path = '/roles' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ListRoles200Response' + + # auth_names + auth_names = opts[:debug_auth_names] || ['BearerApiKey'] + + new_options = opts.merge( + :operation => :"TremendousApi.list_roles", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TremendousApi#list_roles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # List events # Lists all event types that can be sent to the configured webhook endpoint. > 📘 Learn more about Webhooks > > Our guide explains everything you need to know about the Tremendous webhooks: > [Read it here](/docs/webhooks-1) # @param id [String] ID of the webhook to list the events for @@ -2488,6 +2874,85 @@ def simulate_webhook_with_http_info(id, simulate_webhook_request, opts = {}) return data, status_code, headers end + # Test public key + # Making a request to this endpoint with a JWT signed with your private key will return a 200 response if the public key is active and the signature is valid. > 💡 Testing your integration > > **You can use [JWT.io](https://jwt.io/) to generate a signed token:** > > > 1. Select “RS256” in their algorithm dropdown; > 3. Define a JSON payload such as `{ \"foo\": \"bar\" }`; > 4. Fill the “Verify signature” fields with your public and private keys and copy the “Encoded” token. + # @param id [String] ID of the public key to test + # @param test_public_key_request [TestPublicKeyRequest] + # @param [Hash] opts the optional parameters + # @return [nil] + def test_public_key(id, test_public_key_request, opts = {}) + test_public_key_with_http_info(id, test_public_key_request, opts) + nil + end + + # Test public key + # Making a request to this endpoint with a JWT signed with your private key will return a 200 response if the public key is active and the signature is valid. > 💡 Testing your integration > > **You can use [JWT.io](https://jwt.io/) to generate a signed token:** > > > 1. Select “RS256” in their algorithm dropdown; > 3. Define a JSON payload such as `{ \"foo\": \"bar\" }`; > 4. Fill the “Verify signature” fields with your public and private keys and copy the “Encoded” token. + # @param id [String] ID of the public key to test + # @param test_public_key_request [TestPublicKeyRequest] + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def test_public_key_with_http_info(id, test_public_key_request, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TremendousApi.test_public_key ...' + end + # verify the required parameter 'id' is set + if @api_client.config.client_side_validation && id.nil? + fail ArgumentError, "Missing the required parameter 'id' when calling TremendousApi.test_public_key" + end + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if @api_client.config.client_side_validation && id !~ pattern + fail ArgumentError, "invalid value for 'id' when calling TremendousApi.test_public_key, must conform to the pattern #{pattern}." + end + + # verify the required parameter 'test_public_key_request' is set + if @api_client.config.client_side_validation && test_public_key_request.nil? + fail ArgumentError, "Missing the required parameter 'test_public_key_request' when calling TremendousApi.test_public_key" + end + # resource path + local_var_path = '/public_keys/{id}/decode_jwt'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(test_public_key_request) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['BearerApiKey'] + + new_options = opts.merge( + :operation => :"TremendousApi.test_public_key", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TremendousApi#test_public_key\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Update campaign # @param id [String] ID of the campaign that should be updated # @param update_campaign_request [UpdateCampaignRequest] Campaign details diff --git a/lib/tremendous/models/create_member.rb b/lib/tremendous/models/create_member.rb index 429bda7..0689b07 100644 --- a/lib/tremendous/models/create_member.rb +++ b/lib/tremendous/models/create_member.rb @@ -18,31 +18,9 @@ class CreateMember # Email address of the member attr_accessor :email - # Role of the member within the organization.
Role Description
MEMBER Limited permissions. Can view their own reward and order histories only.
ADMIN Update organization settings, invite other members to the organization, and view all member order and reward histories within their organization.
+ # The role ID of the member within the organization. attr_accessor :role - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -120,21 +98,9 @@ def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @email.nil? return false if @role.nil? - role_validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - return false unless role_validator.valid?(@role) true end - # Custom attribute writer method checking allowed values (enum). - # @param [Object] role Object to be assigned - def role=(role) - validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - unless validator.valid?(role) - fail ArgumentError, "invalid value for \"role\", must be one of #{validator.allowable_values}." - end - @role = role - end - # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) diff --git a/lib/tremendous/models/create_member_request.rb b/lib/tremendous/models/create_member_request.rb index d40211a..1d2b58c 100644 --- a/lib/tremendous/models/create_member_request.rb +++ b/lib/tremendous/models/create_member_request.rb @@ -18,31 +18,9 @@ class CreateMemberRequest # Email address of the member attr_accessor :email - # Role of the member within the organization.
Role Description
MEMBER Limited permissions. Can view their own reward and order histories only.
ADMIN Update organization settings, invite other members to the organization, and view all member order and reward histories within their organization.
+ # The role ID of the member within the organization. attr_accessor :role - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -120,21 +98,9 @@ def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @email.nil? return false if @role.nil? - role_validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - return false unless role_validator.valid?(@role) true end - # Custom attribute writer method checking allowed values (enum). - # @param [Object] role Object to be assigned - def role=(role) - validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - unless validator.valid?(role) - fail ArgumentError, "invalid value for \"role\", must be one of #{validator.allowable_values}." - end - @role = role - end - # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) diff --git a/lib/tremendous/models/create_organization_request_copy_settings.rb b/lib/tremendous/models/create_organization_request_copy_settings.rb index 7a3c374..c9227bf 100644 --- a/lib/tremendous/models/create_organization_request_copy_settings.rb +++ b/lib/tremendous/models/create_organization_request_copy_settings.rb @@ -31,9 +31,12 @@ class CreateOrganizationRequestCopySettings # Copy over the security settings from the current organization to the new organization. Defaults to `true`. attr_accessor :security_settings - # Copy over the users from the current organization to the new organization. Defaults to `false`. + # Copy over the users and custom roles from the current organization to the new organization. Defaults to `false`. attr_accessor :users + # Copy over the custom roles from the current organization to the new organization. Custom roles are always copied if `users` is `true`. Defaults to `false`. + attr_accessor :custom_roles + # Copy over the fraud prevention settings and rules from the current organization to the new organization. Defaults to `false`. attr_accessor :fraud_prevention @@ -46,6 +49,7 @@ def self.attribute_map :'payment_methods' => :'payment_methods', :'security_settings' => :'security_settings', :'users' => :'users', + :'custom_roles' => :'custom_roles', :'fraud_prevention' => :'fraud_prevention' } end @@ -64,6 +68,7 @@ def self.openapi_types :'payment_methods' => :'Boolean', :'security_settings' => :'Boolean', :'users' => :'Boolean', + :'custom_roles' => :'Boolean', :'fraud_prevention' => :'Boolean' } end @@ -125,6 +130,12 @@ def initialize(attributes = {}) self.users = false end + if attributes.key?(:'custom_roles') + self.custom_roles = attributes[:'custom_roles'] + else + self.custom_roles = false + end + if attributes.key?(:'fraud_prevention') self.fraud_prevention = attributes[:'fraud_prevention'] else @@ -158,6 +169,7 @@ def ==(o) payment_methods == o.payment_methods && security_settings == o.security_settings && users == o.users && + custom_roles == o.custom_roles && fraud_prevention == o.fraud_prevention end @@ -170,7 +182,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [campaigns, custom_fields, order_approvals, payment_methods, security_settings, users, fraud_prevention].hash + [campaigns, custom_fields, order_approvals, payment_methods, security_settings, users, custom_roles, fraud_prevention].hash end # Builds the object from hash diff --git a/lib/tremendous/models/create_public_key.rb b/lib/tremendous/models/create_public_key.rb new file mode 100644 index 0000000..c35d0a4 --- /dev/null +++ b/lib/tremendous/models/create_public_key.rb @@ -0,0 +1,222 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + class CreatePublicKey + # Base64 encoded (public) PEM file + attr_accessor :public_key + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'public_key' => :'public_key' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'public_key' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::CreatePublicKey` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::CreatePublicKey`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'public_key') + self.public_key = attributes[:'public_key'] + else + self.public_key = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @public_key.nil? + invalid_properties.push('invalid value for "public_key", public_key cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @public_key.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + public_key == o.public_key + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [public_key].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Tremendous.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/tremendous/models/create_public_key200_response.rb b/lib/tremendous/models/create_public_key200_response.rb new file mode 100644 index 0000000..3bda6f0 --- /dev/null +++ b/lib/tremendous/models/create_public_key200_response.rb @@ -0,0 +1,221 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + class CreatePublicKey200Response + attr_accessor :public_key + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'public_key' => :'public_key' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'public_key' => :'PublicKeysResponsePublicKeysInner' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::CreatePublicKey200Response` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::CreatePublicKey200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'public_key') + self.public_key = attributes[:'public_key'] + else + self.public_key = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @public_key.nil? + invalid_properties.push('invalid value for "public_key", public_key cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @public_key.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + public_key == o.public_key + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [public_key].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Tremendous.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/tremendous/models/create_public_key_request.rb b/lib/tremendous/models/create_public_key_request.rb new file mode 100644 index 0000000..c4d3c76 --- /dev/null +++ b/lib/tremendous/models/create_public_key_request.rb @@ -0,0 +1,222 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + class CreatePublicKeyRequest + # Base64 encoded (public) PEM file + attr_accessor :public_key + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'public_key' => :'public_key' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'public_key' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::CreatePublicKeyRequest` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::CreatePublicKeyRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'public_key') + self.public_key = attributes[:'public_key'] + else + self.public_key = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @public_key.nil? + invalid_properties.push('invalid value for "public_key", public_key cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @public_key.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + public_key == o.public_key + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [public_key].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Tremendous.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/tremendous/models/get_member200_response_member.rb b/lib/tremendous/models/get_member200_response_member.rb index 141d9e4..619c54c 100644 --- a/lib/tremendous/models/get_member200_response_member.rb +++ b/lib/tremendous/models/get_member200_response_member.rb @@ -27,7 +27,7 @@ class GetMember200ResponseMember # Is this member currently active in the organization. If `false`, the member will not be able to access the organization. attr_accessor :active - # Role of the member within the organization.
Role Description
MEMBER Limited permissions. Can view their own reward and order histories only.
ADMIN Update organization settings, invite other members to the organization, and view all member order and reward histories within their organization.
+ # The role ID associated with the member within the organization. attr_accessor :role # Current status of the member's account. When creating a member it starts out in the status `INVITED`. As soon as that member open the invitation link and registers an account, the status switches to `REGISTERED`. @@ -93,6 +93,7 @@ def self.openapi_types def self.openapi_nullable Set.new([ :'name', + :'role', ]) end @@ -135,8 +136,6 @@ def initialize(attributes = {}) if attributes.key?(:'role') self.role = attributes[:'role'] - else - self.role = nil end if attributes.key?(:'status') @@ -170,10 +169,6 @@ def list_invalid_properties invalid_properties.push('invalid value for "email", email cannot be nil.') end - if @role.nil? - invalid_properties.push('invalid value for "role", role cannot be nil.') - end - if @status.nil? invalid_properties.push('invalid value for "status", status cannot be nil.') end @@ -188,9 +183,6 @@ def valid? return false if @id.nil? return false if @id !~ Regexp.new(/[A-Z0-9]{4,20}/) return false if @email.nil? - return false if @role.nil? - role_validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - return false unless role_validator.valid?(@role) return false if @status.nil? status_validator = EnumAttributeValidator.new('String', ["REGISTERED", "INVITED"]) return false unless status_validator.valid?(@status) @@ -212,16 +204,6 @@ def id=(id) @id = id end - # Custom attribute writer method checking allowed values (enum). - # @param [Object] role Object to be assigned - def role=(role) - validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - unless validator.valid?(role) - fail ArgumentError, "invalid value for \"role\", must be one of #{validator.allowable_values}." - end - @role = role - end - # Custom attribute writer method checking allowed values (enum). # @param [Object] status Object to be assigned def status=(status) diff --git a/lib/tremendous/models/list_members200_response_members_inner.rb b/lib/tremendous/models/list_members200_response_members_inner.rb index e9621fa..33c3041 100644 --- a/lib/tremendous/models/list_members200_response_members_inner.rb +++ b/lib/tremendous/models/list_members200_response_members_inner.rb @@ -27,7 +27,7 @@ class ListMembers200ResponseMembersInner # Is this member currently active in the organization. If `false`, the member will not be able to access the organization. attr_accessor :active - # Role of the member within the organization.
Role Description
MEMBER Limited permissions. Can view their own reward and order histories only.
ADMIN Update organization settings, invite other members to the organization, and view all member order and reward histories within their organization.
+ # The role ID associated with the member within the organization. attr_accessor :role # Current status of the member's account. When creating a member it starts out in the status `INVITED`. As soon as that member open the invitation link and registers an account, the status switches to `REGISTERED`. @@ -98,6 +98,7 @@ def self.openapi_types def self.openapi_nullable Set.new([ :'name', + :'role', :'last_login_at' ]) end @@ -141,8 +142,6 @@ def initialize(attributes = {}) if attributes.key?(:'role') self.role = attributes[:'role'] - else - self.role = nil end if attributes.key?(:'status') @@ -178,10 +177,6 @@ def list_invalid_properties invalid_properties.push('invalid value for "email", email cannot be nil.') end - if @role.nil? - invalid_properties.push('invalid value for "role", role cannot be nil.') - end - if @status.nil? invalid_properties.push('invalid value for "status", status cannot be nil.') end @@ -196,9 +191,6 @@ def valid? return false if @id.nil? return false if @id !~ Regexp.new(/[A-Z0-9]{4,20}/) return false if @email.nil? - return false if @role.nil? - role_validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - return false unless role_validator.valid?(@role) return false if @status.nil? status_validator = EnumAttributeValidator.new('String', ["REGISTERED", "INVITED"]) return false unless status_validator.valid?(@status) @@ -220,16 +212,6 @@ def id=(id) @id = id end - # Custom attribute writer method checking allowed values (enum). - # @param [Object] role Object to be assigned - def role=(role) - validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - unless validator.valid?(role) - fail ArgumentError, "invalid value for \"role\", must be one of #{validator.allowable_values}." - end - @role = role - end - # Custom attribute writer method checking allowed values (enum). # @param [Object] status Object to be assigned def status=(status) diff --git a/lib/tremendous/models/list_roles200_response.rb b/lib/tremendous/models/list_roles200_response.rb new file mode 100644 index 0000000..207fdfa --- /dev/null +++ b/lib/tremendous/models/list_roles200_response.rb @@ -0,0 +1,223 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + class ListRoles200Response + attr_accessor :roles + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'roles' => :'roles' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'roles' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::ListRoles200Response` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListRoles200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'roles') + if (value = attributes[:'roles']).is_a?(Array) + self.roles = value + end + else + self.roles = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @roles.nil? + invalid_properties.push('invalid value for "roles", roles cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @roles.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + roles == o.roles + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [roles].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Tremendous.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/tremendous/models/list_roles200_response_roles_inner.rb b/lib/tremendous/models/list_roles200_response_roles_inner.rb new file mode 100644 index 0000000..6a4315a --- /dev/null +++ b/lib/tremendous/models/list_roles200_response_roles_inner.rb @@ -0,0 +1,275 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # Each organization member is assigned a role that defines the permissions they have within the organization. + class ListRoles200ResponseRolesInner + attr_accessor :id + + attr_accessor :title + + attr_accessor :description + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'title' => :'title', + :'description' => :'description' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'title' => :'String', + :'description' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::ListRoles200ResponseRolesInner` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListRoles200ResponseRolesInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'title') + self.title = attributes[:'title'] + else + self.title = nil + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + else + self.description = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if @id !~ pattern + invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.") + end + + if @title.nil? + invalid_properties.push('invalid value for "title", title cannot be nil.') + end + + if @description.nil? + invalid_properties.push('invalid value for "description", description cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @id !~ Regexp.new(/[A-Z0-9]{4,20}/) + return false if @title.nil? + return false if @description.nil? + true + end + + # Custom attribute writer method with validation + # @param [Object] id Value to be assigned + def id=(id) + if id.nil? + fail ArgumentError, 'id cannot be nil' + end + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if id !~ pattern + fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}." + end + + @id = id + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + title == o.title && + description == o.description + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, title, description].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Tremendous.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/tremendous/models/member.rb b/lib/tremendous/models/member.rb index 2746e59..5a27f1e 100644 --- a/lib/tremendous/models/member.rb +++ b/lib/tremendous/models/member.rb @@ -27,7 +27,7 @@ class Member # Is this member currently active in the organization. If `false`, the member will not be able to access the organization. attr_accessor :active - # Role of the member within the organization.
Role Description
MEMBER Limited permissions. Can view their own reward and order histories only.
ADMIN Update organization settings, invite other members to the organization, and view all member order and reward histories within their organization.
+ # The role ID associated with the member within the organization. attr_accessor :role # Current status of the member's account. When creating a member it starts out in the status `INVITED`. As soon as that member open the invitation link and registers an account, the status switches to `REGISTERED`. @@ -98,6 +98,7 @@ def self.openapi_types def self.openapi_nullable Set.new([ :'name', + :'role', :'last_login_at' ]) end @@ -141,8 +142,6 @@ def initialize(attributes = {}) if attributes.key?(:'role') self.role = attributes[:'role'] - else - self.role = nil end if attributes.key?(:'status') @@ -178,10 +177,6 @@ def list_invalid_properties invalid_properties.push('invalid value for "email", email cannot be nil.') end - if @role.nil? - invalid_properties.push('invalid value for "role", role cannot be nil.') - end - if @status.nil? invalid_properties.push('invalid value for "status", status cannot be nil.') end @@ -196,9 +191,6 @@ def valid? return false if @id.nil? return false if @id !~ Regexp.new(/[A-Z0-9]{4,20}/) return false if @email.nil? - return false if @role.nil? - role_validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - return false unless role_validator.valid?(@role) return false if @status.nil? status_validator = EnumAttributeValidator.new('String', ["REGISTERED", "INVITED"]) return false unless status_validator.valid?(@status) @@ -220,16 +212,6 @@ def id=(id) @id = id end - # Custom attribute writer method checking allowed values (enum). - # @param [Object] role Object to be assigned - def role=(role) - validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - unless validator.valid?(role) - fail ArgumentError, "invalid value for \"role\", must be one of #{validator.allowable_values}." - end - @role = role - end - # Custom attribute writer method checking allowed values (enum). # @param [Object] status Object to be assigned def status=(status) diff --git a/lib/tremendous/models/member_base.rb b/lib/tremendous/models/member_base.rb index 2f27d0b..ca62507 100644 --- a/lib/tremendous/models/member_base.rb +++ b/lib/tremendous/models/member_base.rb @@ -27,7 +27,7 @@ class MemberBase # Is this member currently active in the organization. If `false`, the member will not be able to access the organization. attr_accessor :active - # Role of the member within the organization.
Role Description
MEMBER Limited permissions. Can view their own reward and order histories only.
ADMIN Update organization settings, invite other members to the organization, and view all member order and reward histories within their organization.
+ # The role ID associated with the member within the organization. attr_accessor :role # Current status of the member's account. When creating a member it starts out in the status `INVITED`. As soon as that member open the invitation link and registers an account, the status switches to `REGISTERED`. @@ -88,6 +88,7 @@ def self.openapi_types def self.openapi_nullable Set.new([ :'name', + :'role', ]) end @@ -130,8 +131,6 @@ def initialize(attributes = {}) if attributes.key?(:'role') self.role = attributes[:'role'] - else - self.role = nil end if attributes.key?(:'status') @@ -159,10 +158,6 @@ def list_invalid_properties invalid_properties.push('invalid value for "email", email cannot be nil.') end - if @role.nil? - invalid_properties.push('invalid value for "role", role cannot be nil.') - end - if @status.nil? invalid_properties.push('invalid value for "status", status cannot be nil.') end @@ -177,9 +172,6 @@ def valid? return false if @id.nil? return false if @id !~ Regexp.new(/[A-Z0-9]{4,20}/) return false if @email.nil? - return false if @role.nil? - role_validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - return false unless role_validator.valid?(@role) return false if @status.nil? status_validator = EnumAttributeValidator.new('String', ["REGISTERED", "INVITED"]) return false unless status_validator.valid?(@status) @@ -201,16 +193,6 @@ def id=(id) @id = id end - # Custom attribute writer method checking allowed values (enum). - # @param [Object] role Object to be assigned - def role=(role) - validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - unless validator.valid?(role) - fail ArgumentError, "invalid value for \"role\", must be one of #{validator.allowable_values}." - end - @role = role - end - # Custom attribute writer method checking allowed values (enum). # @param [Object] status Object to be assigned def status=(status) diff --git a/lib/tremendous/models/member_with_events.rb b/lib/tremendous/models/member_with_events.rb index dbb3560..aaca507 100644 --- a/lib/tremendous/models/member_with_events.rb +++ b/lib/tremendous/models/member_with_events.rb @@ -27,7 +27,7 @@ class MemberWithEvents # Is this member currently active in the organization. If `false`, the member will not be able to access the organization. attr_accessor :active - # Role of the member within the organization.
Role Description
MEMBER Limited permissions. Can view their own reward and order histories only.
ADMIN Update organization settings, invite other members to the organization, and view all member order and reward histories within their organization.
+ # The role ID associated with the member within the organization. attr_accessor :role # Current status of the member's account. When creating a member it starts out in the status `INVITED`. As soon as that member open the invitation link and registers an account, the status switches to `REGISTERED`. @@ -93,6 +93,7 @@ def self.openapi_types def self.openapi_nullable Set.new([ :'name', + :'role', ]) end @@ -135,8 +136,6 @@ def initialize(attributes = {}) if attributes.key?(:'role') self.role = attributes[:'role'] - else - self.role = nil end if attributes.key?(:'status') @@ -170,10 +169,6 @@ def list_invalid_properties invalid_properties.push('invalid value for "email", email cannot be nil.') end - if @role.nil? - invalid_properties.push('invalid value for "role", role cannot be nil.') - end - if @status.nil? invalid_properties.push('invalid value for "status", status cannot be nil.') end @@ -188,9 +183,6 @@ def valid? return false if @id.nil? return false if @id !~ Regexp.new(/[A-Z0-9]{4,20}/) return false if @email.nil? - return false if @role.nil? - role_validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - return false unless role_validator.valid?(@role) return false if @status.nil? status_validator = EnumAttributeValidator.new('String', ["REGISTERED", "INVITED"]) return false unless status_validator.valid?(@status) @@ -212,16 +204,6 @@ def id=(id) @id = id end - # Custom attribute writer method checking allowed values (enum). - # @param [Object] role Object to be assigned - def role=(role) - validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - unless validator.valid?(role) - fail ArgumentError, "invalid value for \"role\", must be one of #{validator.allowable_values}." - end - @role = role - end - # Custom attribute writer method checking allowed values (enum). # @param [Object] status Object to be assigned def status=(status) diff --git a/lib/tremendous/models/member_without_events.rb b/lib/tremendous/models/member_without_events.rb index db3bea1..aaafbb9 100644 --- a/lib/tremendous/models/member_without_events.rb +++ b/lib/tremendous/models/member_without_events.rb @@ -27,7 +27,7 @@ class MemberWithoutEvents # Is this member currently active in the organization. If `false`, the member will not be able to access the organization. attr_accessor :active - # Role of the member within the organization.
Role Description
MEMBER Limited permissions. Can view their own reward and order histories only.
ADMIN Update organization settings, invite other members to the organization, and view all member order and reward histories within their organization.
+ # The role ID associated with the member within the organization. attr_accessor :role # Current status of the member's account. When creating a member it starts out in the status `INVITED`. As soon as that member open the invitation link and registers an account, the status switches to `REGISTERED`. @@ -98,6 +98,7 @@ def self.openapi_types def self.openapi_nullable Set.new([ :'name', + :'role', :'last_login_at' ]) end @@ -141,8 +142,6 @@ def initialize(attributes = {}) if attributes.key?(:'role') self.role = attributes[:'role'] - else - self.role = nil end if attributes.key?(:'status') @@ -178,10 +177,6 @@ def list_invalid_properties invalid_properties.push('invalid value for "email", email cannot be nil.') end - if @role.nil? - invalid_properties.push('invalid value for "role", role cannot be nil.') - end - if @status.nil? invalid_properties.push('invalid value for "status", status cannot be nil.') end @@ -196,9 +191,6 @@ def valid? return false if @id.nil? return false if @id !~ Regexp.new(/[A-Z0-9]{4,20}/) return false if @email.nil? - return false if @role.nil? - role_validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - return false unless role_validator.valid?(@role) return false if @status.nil? status_validator = EnumAttributeValidator.new('String', ["REGISTERED", "INVITED"]) return false unless status_validator.valid?(@status) @@ -220,16 +212,6 @@ def id=(id) @id = id end - # Custom attribute writer method checking allowed values (enum). - # @param [Object] role Object to be assigned - def role=(role) - validator = EnumAttributeValidator.new('String', ["MEMBER", "ADMIN"]) - unless validator.valid?(role) - fail ArgumentError, "invalid value for \"role\", must be one of #{validator.allowable_values}." - end - @role = role - end - # Custom attribute writer method checking allowed values (enum). # @param [Object] status Object to be assigned def status=(status) diff --git a/lib/tremendous/models/public_key.rb b/lib/tremendous/models/public_key.rb new file mode 100644 index 0000000..c698952 --- /dev/null +++ b/lib/tremendous/models/public_key.rb @@ -0,0 +1,257 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # To authenticate your requests using asymmetric key pairs (e.g., for signing embed requests), you need to share your public key with us. The public key resource allows you to manage your active public keys and track their last usage. + class PublicKey + attr_accessor :id + + # Your public key, PEM encoded + attr_accessor :pem + + # The last time your public key was used to sign a request + attr_accessor :last_used_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'pem' => :'pem', + :'last_used_at' => :'last_used_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'pem' => :'String', + :'last_used_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'last_used_at' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::PublicKey` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::PublicKey`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'pem') + self.pem = attributes[:'pem'] + end + + if attributes.key?(:'last_used_at') + self.last_used_at = attributes[:'last_used_at'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !@id.nil? && @id !~ pattern + invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.") + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if !@id.nil? && @id !~ Regexp.new(/[A-Z0-9]{4,20}/) + true + end + + # Custom attribute writer method with validation + # @param [Object] id Value to be assigned + def id=(id) + if id.nil? + fail ArgumentError, 'id cannot be nil' + end + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if id !~ pattern + fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}." + end + + @id = id + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + pem == o.pem && + last_used_at == o.last_used_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, pem, last_used_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Tremendous.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/tremendous/models/public_keys_response.rb b/lib/tremendous/models/public_keys_response.rb new file mode 100644 index 0000000..81278b1 --- /dev/null +++ b/lib/tremendous/models/public_keys_response.rb @@ -0,0 +1,223 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + class PublicKeysResponse + attr_accessor :public_keys + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'public_keys' => :'public_keys' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'public_keys' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::PublicKeysResponse` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::PublicKeysResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'public_keys') + if (value = attributes[:'public_keys']).is_a?(Array) + self.public_keys = value + end + else + self.public_keys = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @public_keys.nil? + invalid_properties.push('invalid value for "public_keys", public_keys cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @public_keys.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + public_keys == o.public_keys + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [public_keys].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Tremendous.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/tremendous/models/public_keys_response_public_keys_inner.rb b/lib/tremendous/models/public_keys_response_public_keys_inner.rb new file mode 100644 index 0000000..1841a2f --- /dev/null +++ b/lib/tremendous/models/public_keys_response_public_keys_inner.rb @@ -0,0 +1,257 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # To authenticate your requests using asymmetric key pairs (e.g., for signing embed requests), you need to share your public key with us. The public key resource allows you to manage your active public keys and track their last usage. + class PublicKeysResponsePublicKeysInner + attr_accessor :id + + # Your public key, PEM encoded + attr_accessor :pem + + # The last time your public key was used to sign a request + attr_accessor :last_used_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'pem' => :'pem', + :'last_used_at' => :'last_used_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'pem' => :'String', + :'last_used_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'last_used_at' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::PublicKeysResponsePublicKeysInner` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::PublicKeysResponsePublicKeysInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'pem') + self.pem = attributes[:'pem'] + end + + if attributes.key?(:'last_used_at') + self.last_used_at = attributes[:'last_used_at'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !@id.nil? && @id !~ pattern + invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.") + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if !@id.nil? && @id !~ Regexp.new(/[A-Z0-9]{4,20}/) + true + end + + # Custom attribute writer method with validation + # @param [Object] id Value to be assigned + def id=(id) + if id.nil? + fail ArgumentError, 'id cannot be nil' + end + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if id !~ pattern + fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}." + end + + @id = id + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + pem == o.pem && + last_used_at == o.last_used_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, pem, last_used_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Tremendous.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/tremendous/models/role.rb b/lib/tremendous/models/role.rb new file mode 100644 index 0000000..e28ea95 --- /dev/null +++ b/lib/tremendous/models/role.rb @@ -0,0 +1,275 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # Each organization member is assigned a role that defines the permissions they have within the organization. + class Role + attr_accessor :id + + attr_accessor :title + + attr_accessor :description + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'title' => :'title', + :'description' => :'description' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'title' => :'String', + :'description' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::Role` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::Role`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'title') + self.title = attributes[:'title'] + else + self.title = nil + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + else + self.description = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if @id !~ pattern + invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.") + end + + if @title.nil? + invalid_properties.push('invalid value for "title", title cannot be nil.') + end + + if @description.nil? + invalid_properties.push('invalid value for "description", description cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @id !~ Regexp.new(/[A-Z0-9]{4,20}/) + return false if @title.nil? + return false if @description.nil? + true + end + + # Custom attribute writer method with validation + # @param [Object] id Value to be assigned + def id=(id) + if id.nil? + fail ArgumentError, 'id cannot be nil' + end + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if id !~ pattern + fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}." + end + + @id = id + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + title == o.title && + description == o.description + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, title, description].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Tremendous.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/tremendous/models/test_public_key.rb b/lib/tremendous/models/test_public_key.rb new file mode 100644 index 0000000..b4c0ceb --- /dev/null +++ b/lib/tremendous/models/test_public_key.rb @@ -0,0 +1,222 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + class TestPublicKey + # A JWT token encoded with RS256, signed using the RSA private key corresponding to your public key. + attr_accessor :jwt + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'jwt' => :'jwt' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'jwt' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::TestPublicKey` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::TestPublicKey`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'jwt') + self.jwt = attributes[:'jwt'] + else + self.jwt = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @jwt.nil? + invalid_properties.push('invalid value for "jwt", jwt cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @jwt.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + jwt == o.jwt + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [jwt].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Tremendous.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/tremendous/models/test_public_key_request.rb b/lib/tremendous/models/test_public_key_request.rb new file mode 100644 index 0000000..12ba924 --- /dev/null +++ b/lib/tremendous/models/test_public_key_request.rb @@ -0,0 +1,222 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + class TestPublicKeyRequest + # A JWT token encoded with RS256, signed using the RSA private key corresponding to your public key. + attr_accessor :jwt + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'jwt' => :'jwt' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'jwt' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::TestPublicKeyRequest` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::TestPublicKeyRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'jwt') + self.jwt = attributes[:'jwt'] + else + self.jwt = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @jwt.nil? + invalid_properties.push('invalid value for "jwt", jwt cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @jwt.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + jwt == o.jwt + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [jwt].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Tremendous.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/tremendous/version.rb b/lib/tremendous/version.rb index 62dca0c..c9fc077 100644 --- a/lib/tremendous/version.rb +++ b/lib/tremendous/version.rb @@ -1,3 +1,3 @@ module Tremendous - VERSION = "5.2.0" + VERSION = "5.3.0" end