diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 6ccfd91..bd1b7b3 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -21,10 +21,16 @@ lib/tremendous/models/create_member.rb lib/tremendous/models/create_member200_response.rb lib/tremendous/models/create_member_request.rb lib/tremendous/models/create_order200_response.rb +lib/tremendous/models/create_order200_response_order.rb +lib/tremendous/models/create_order200_response_order_rewards_inner.rb +lib/tremendous/models/create_order200_response_order_rewards_inner_delivery.rb +lib/tremendous/models/create_order201_response.rb lib/tremendous/models/create_order_request.rb lib/tremendous/models/create_organization.rb lib/tremendous/models/create_organization200_response.rb lib/tremendous/models/create_organization200_response_organization.rb +lib/tremendous/models/create_organization_for_response.rb +lib/tremendous/models/create_organization_properties.rb lib/tremendous/models/create_organization_request.rb lib/tremendous/models/create_organization_request_copy_settings.rb lib/tremendous/models/create_webhook200_response.rb @@ -33,6 +39,7 @@ lib/tremendous/models/currency_codes.rb lib/tremendous/models/custom_field.rb lib/tremendous/models/delete_fraud_rule200_response.rb lib/tremendous/models/delivery_details.rb +lib/tremendous/models/delivery_details_with_link.rb lib/tremendous/models/delivery_method.rb lib/tremendous/models/delivery_status.rb lib/tremendous/models/error_model.rb @@ -130,11 +137,14 @@ lib/tremendous/models/order.rb lib/tremendous/models/order_base.rb lib/tremendous/models/order_base_payment.rb lib/tremendous/models/order_status.rb +lib/tremendous/models/order_with_link.rb +lib/tremendous/models/order_with_link_rewards_inner.rb lib/tremendous/models/order_without_link.rb lib/tremendous/models/order_without_link_rewards_inner.rb lib/tremendous/models/organization.rb lib/tremendous/models/payment_details.rb lib/tremendous/models/payment_details_refund.rb +lib/tremendous/models/payout.rb lib/tremendous/models/product.rb lib/tremendous/models/recipient.rb lib/tremendous/models/refund_details.rb @@ -154,6 +164,8 @@ lib/tremendous/models/reward_for_order_create.rb lib/tremendous/models/reward_link.rb lib/tremendous/models/reward_token.rb lib/tremendous/models/reward_value.rb +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 @@ -163,6 +175,8 @@ lib/tremendous/models/single_reward_order_payment.rb lib/tremendous/models/single_reward_order_reward.rb lib/tremendous/models/single_reward_order_reward_custom_fields_inner.rb lib/tremendous/models/single_reward_order_reward_delivery.rb +lib/tremendous/models/single_reward_order_with_link.rb +lib/tremendous/models/single_reward_order_with_link_order.rb lib/tremendous/models/single_reward_order_without_link.rb lib/tremendous/models/single_reward_order_without_link_order.rb lib/tremendous/models/update_campaign.rb diff --git a/lib/tremendous.rb b/lib/tremendous.rb index c6da843..27caa93 100644 --- a/lib/tremendous.rb +++ b/lib/tremendous.rb @@ -35,10 +35,16 @@ require 'tremendous/models/create_member200_response' require 'tremendous/models/create_member_request' require 'tremendous/models/create_order200_response' +require 'tremendous/models/create_order200_response_order' +require 'tremendous/models/create_order200_response_order_rewards_inner' +require 'tremendous/models/create_order200_response_order_rewards_inner_delivery' +require 'tremendous/models/create_order201_response' require 'tremendous/models/create_order_request' require 'tremendous/models/create_organization' require 'tremendous/models/create_organization200_response' require 'tremendous/models/create_organization200_response_organization' +require 'tremendous/models/create_organization_for_response' +require 'tremendous/models/create_organization_properties' require 'tremendous/models/create_organization_request' require 'tremendous/models/create_organization_request_copy_settings' require 'tremendous/models/create_webhook200_response' @@ -47,6 +53,7 @@ require 'tremendous/models/custom_field' require 'tremendous/models/delete_fraud_rule200_response' require 'tremendous/models/delivery_details' +require 'tremendous/models/delivery_details_with_link' require 'tremendous/models/delivery_method' require 'tremendous/models/delivery_status' require 'tremendous/models/error_model' @@ -144,11 +151,14 @@ require 'tremendous/models/order_base' require 'tremendous/models/order_base_payment' require 'tremendous/models/order_status' +require 'tremendous/models/order_with_link' +require 'tremendous/models/order_with_link_rewards_inner' require 'tremendous/models/order_without_link' require 'tremendous/models/order_without_link_rewards_inner' require 'tremendous/models/organization' require 'tremendous/models/payment_details' require 'tremendous/models/payment_details_refund' +require 'tremendous/models/payout' require 'tremendous/models/product' require 'tremendous/models/recipient' require 'tremendous/models/refund_details' @@ -168,6 +178,8 @@ require 'tremendous/models/reward_link' require 'tremendous/models/reward_token' require 'tremendous/models/reward_value' +require 'tremendous/models/reward_with_link' +require 'tremendous/models/reward_with_link_delivery' require 'tremendous/models/reward_without_link' require 'tremendous/models/reward_without_link_delivery' require 'tremendous/models/role' @@ -177,6 +189,8 @@ require 'tremendous/models/single_reward_order_reward' require 'tremendous/models/single_reward_order_reward_custom_fields_inner' require 'tremendous/models/single_reward_order_reward_delivery' +require 'tremendous/models/single_reward_order_with_link' +require 'tremendous/models/single_reward_order_with_link_order' require 'tremendous/models/single_reward_order_without_link' require 'tremendous/models/single_reward_order_without_link_order' require 'tremendous/models/update_campaign' diff --git a/lib/tremendous/api/tremendous_api.rb b/lib/tremendous/api/tremendous_api.rb index 9c8ee39..fa380b0 100644 --- a/lib/tremendous/api/tremendous_api.rb +++ b/lib/tremendous/api/tremendous_api.rb @@ -23,7 +23,7 @@ def initialize(api_client = ApiClient.default) # Approves an order that is pending review, identified by the given `id` in the URL. Approvals is a feature that requires orders to be approved by an organization admin before they are sent out. To enable approvals for your organization, please enable 'Allow approvals via API' via the organization''s 'Order Approvals' settings from the Tremendous dashboard. # @param id [String] ID of the order that should be approved. In case the order has an `external_id` reference supplied by the customer on creation, it's possible to use it instead. # @param [Hash] opts the optional parameters - # @return [CreateOrder200Response] + # @return [CreateOrder201Response] def approve_order(id, opts = {}) data, _status_code, _headers = approve_order_with_http_info(id, opts) data @@ -33,7 +33,7 @@ def approve_order(id, opts = {}) # Approves an order that is pending review, identified by the given `id` in the URL. Approvals is a feature that requires orders to be approved by an organization admin before they are sent out. To enable approvals for your organization, please enable 'Allow approvals via API' via the organization''s 'Order Approvals' settings from the Tremendous dashboard. # @param id [String] ID of the order that should be approved. In case the order has an `external_id` reference supplied by the customer on creation, it's possible to use it instead. # @param [Hash] opts the optional parameters - # @return [Array<(CreateOrder200Response, Integer, Hash)>] CreateOrder200Response data, response status code and response headers + # @return [Array<(CreateOrder201Response, Integer, Hash)>] CreateOrder201Response data, response status code and response headers def approve_order_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TremendousApi.approve_order ...' @@ -65,7 +65,7 @@ def approve_order_with_http_info(id, opts = {}) post_body = opts[:debug_body] # return_type - return_type = opts[:debug_return_type] || 'CreateOrder200Response' + return_type = opts[:debug_return_type] || 'CreateOrder201Response' # auth_names auth_names = opts[:debug_auth_names] || ['BearerApiKey'] @@ -1481,7 +1481,7 @@ def get_member_with_http_info(id, opts = {}) # Retrieve the order, identified by the given `id` in the URL # @param id [String] ID of the order that should be retrieved. In case the order has an `external_id` reference supplied by the customer on creation, it's possible to use it instead. # @param [Hash] opts the optional parameters - # @return [CreateOrder200Response] + # @return [CreateOrder201Response] def get_order(id, opts = {}) data, _status_code, _headers = get_order_with_http_info(id, opts) data @@ -1491,7 +1491,7 @@ def get_order(id, opts = {}) # Retrieve the order, identified by the given `id` in the URL # @param id [String] ID of the order that should be retrieved. In case the order has an `external_id` reference supplied by the customer on creation, it's possible to use it instead. # @param [Hash] opts the optional parameters - # @return [Array<(CreateOrder200Response, Integer, Hash)>] CreateOrder200Response data, response status code and response headers + # @return [Array<(CreateOrder201Response, Integer, Hash)>] CreateOrder201Response data, response status code and response headers def get_order_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TremendousApi.get_order ...' @@ -1518,7 +1518,7 @@ def get_order_with_http_info(id, opts = {}) post_body = opts[:debug_body] # return_type - return_type = opts[:debug_return_type] || 'CreateOrder200Response' + return_type = opts[:debug_return_type] || 'CreateOrder201Response' # auth_names auth_names = opts[:debug_auth_names] || ['BearerApiKey'] @@ -2822,7 +2822,7 @@ def list_webhooks_with_http_info(opts = {}) # Rejects an order that is pending review, identified by the given `id` in the URL. Approvals is a feature that requires orders to be approved by an organization admin before they are sent out. To enable approvals for your organization, please enable 'Allow approvals via API' via the organization''s 'Order Approvals' settings from the Tremendous dashboard. # @param id [String] ID of the order that should be rejected. In case the order has an `external_id` reference supplied by the customer on creation, it's possible to use it instead. # @param [Hash] opts the optional parameters - # @return [CreateOrder200Response] + # @return [CreateOrder201Response] def reject_order(id, opts = {}) data, _status_code, _headers = reject_order_with_http_info(id, opts) data @@ -2832,7 +2832,7 @@ def reject_order(id, opts = {}) # Rejects an order that is pending review, identified by the given `id` in the URL. Approvals is a feature that requires orders to be approved by an organization admin before they are sent out. To enable approvals for your organization, please enable 'Allow approvals via API' via the organization''s 'Order Approvals' settings from the Tremendous dashboard. # @param id [String] ID of the order that should be rejected. In case the order has an `external_id` reference supplied by the customer on creation, it's possible to use it instead. # @param [Hash] opts the optional parameters - # @return [Array<(CreateOrder200Response, Integer, Hash)>] CreateOrder200Response data, response status code and response headers + # @return [Array<(CreateOrder201Response, Integer, Hash)>] CreateOrder201Response data, response status code and response headers def reject_order_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TremendousApi.reject_order ...' @@ -2864,7 +2864,7 @@ def reject_order_with_http_info(id, opts = {}) post_body = opts[:debug_body] # return_type - return_type = opts[:debug_return_type] || 'CreateOrder200Response' + return_type = opts[:debug_return_type] || 'CreateOrder201Response' # auth_names auth_names = opts[:debug_auth_names] || ['BearerApiKey'] diff --git a/lib/tremendous/models/create_order200_response.rb b/lib/tremendous/models/create_order200_response.rb index 7e38a74..3af4701 100644 --- a/lib/tremendous/models/create_order200_response.rb +++ b/lib/tremendous/models/create_order200_response.rb @@ -32,7 +32,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { - :'order' => :'ListOrders200ResponseOrdersInner' + :'order' => :'CreateOrder200ResponseOrder' } end diff --git a/lib/tremendous/models/create_order200_response_order.rb b/lib/tremendous/models/create_order200_response_order.rb new file mode 100644 index 0000000..f8941af --- /dev/null +++ b/lib/tremendous/models/create_order200_response_order.rb @@ -0,0 +1,403 @@ +=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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # An order wraps around the fulfilment of one or more rewards. + class CreateOrder200ResponseOrder + # Tremendous ID of the order + attr_accessor :id + + # Reference for this order, supplied by the customer. When set, `external_id` makes order idempotent. All requests that use the same `external_id` after the initial order creation, will result in a response that returns the data of the initially created order. The response will have a `201` response code. These responses **fail** to create any further orders. It also allows for retrieving by `external_id` instead of `id` only. + attr_accessor :external_id + + # ID of the campaign in your account, that defines the available products (different gift cards, charity, etc.) that the recipient can choose from. + attr_accessor :campaign_id + + # Date the order has been created + attr_accessor :created_at + + # Execution status of a given order
Status Description
CANCELED The order and all of its rewards were canceled.
CART The order has been created, but hasn't yet been processed.
EXECUTED The order has been executed. Payment has been handled and rewards are being delivered (if applicable).
FAILED The order could not be processed due to an error. E.g. due to insufficient funds in the account.
PENDING APPROVAL The order has been created but needs approval to be executed.
PENDING INTERNAL PAYMENT APPROVAL The order has been created but it is under review and requires approval from our team.
+ attr_accessor :status + + # Name of the channel in which the order was created + attr_accessor :channel + + attr_accessor :payment + + # The ID for the invoice associated with this order + attr_accessor :invoice_id + + attr_accessor :rewards + + 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 + { + :'id' => :'id', + :'external_id' => :'external_id', + :'campaign_id' => :'campaign_id', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'payment' => :'payment', + :'invoice_id' => :'invoice_id', + :'rewards' => :'rewards' + } + 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', + :'external_id' => :'String', + :'campaign_id' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'payment' => :'ListOrders200ResponseOrdersInnerPayment', + :'invoice_id' => :'String', + :'rewards' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'external_id', + :'campaign_id', + ]) + 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::CreateOrder200ResponseOrder` 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::CreateOrder200ResponseOrder`. 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?(:'external_id') + self.external_id = attributes[:'external_id'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'payment') + self.payment = attributes[:'payment'] + end + + if attributes.key?(:'invoice_id') + self.invoice_id = attributes[:'invoice_id'] + end + + if attributes.key?(:'rewards') + if (value = attributes[:'rewards']).is_a?(Array) + self.rewards = value + end + 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 + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !@campaign_id.nil? && @campaign_id !~ pattern + invalid_properties.push("invalid value for \"campaign_id\", must conform to the pattern #{pattern}.") + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status 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 !@campaign_id.nil? && @campaign_id !~ Regexp.new(/[A-Z0-9]{4,20}/) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["CANCELED", "CART", "EXECUTED", "FAILED", "PENDING APPROVAL", "PENDING INTERNAL PAYMENT APPROVAL"]) + return false unless status_validator.valid?(@status) + channel_validator = EnumAttributeValidator.new('String', ["UI", "API", "EMBED", "DECIPHER", "QUALTRICS", "TYPEFORM", "SURVEY MONKEY"]) + return false unless channel_validator.valid?(@channel) + 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 + + # Custom attribute writer method with validation + # @param [Object] campaign_id Value to be assigned + def campaign_id=(campaign_id) + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !campaign_id.nil? && campaign_id !~ pattern + fail ArgumentError, "invalid value for \"campaign_id\", must conform to the pattern #{pattern}." + end + + @campaign_id = campaign_id + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CANCELED", "CART", "EXECUTED", "FAILED", "PENDING APPROVAL", "PENDING INTERNAL PAYMENT APPROVAL"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] channel Object to be assigned + def channel=(channel) + validator = EnumAttributeValidator.new('String', ["UI", "API", "EMBED", "DECIPHER", "QUALTRICS", "TYPEFORM", "SURVEY MONKEY"]) + unless validator.valid?(channel) + fail ArgumentError, "invalid value for \"channel\", must be one of #{validator.allowable_values}." + end + @channel = channel + 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 && + external_id == o.external_id && + campaign_id == o.campaign_id && + created_at == o.created_at && + status == o.status && + channel == o.channel && + payment == o.payment && + invoice_id == o.invoice_id && + rewards == o.rewards + 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, external_id, campaign_id, created_at, status, channel, payment, invoice_id, rewards].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_order200_response_order_rewards_inner.rb b/lib/tremendous/models/create_order200_response_order_rewards_inner.rb new file mode 100644 index 0000000..358fb41 --- /dev/null +++ b/lib/tremendous/models/create_order200_response_order_rewards_inner.rb @@ -0,0 +1,326 @@ +=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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # A single reward, sent to a recipient. A reward is always part of an order. Either `products` or `campaign_id` must be specified. + class CreateOrder200ResponseOrderRewardsInner + # Tremendous ID of the reward + attr_accessor :id + + # Tremendous ID of the order this reward is part of. + attr_accessor :order_id + + # Date the reward was created + attr_accessor :created_at + + attr_accessor :value + + attr_accessor :recipient + + # Timestamp of reward delivery within the next year. Note that if date-time is provided, the time values will be ignored. + attr_accessor :deliver_at + + attr_accessor :custom_fields + + attr_accessor :delivery + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'order_id' => :'order_id', + :'created_at' => :'created_at', + :'value' => :'value', + :'recipient' => :'recipient', + :'deliver_at' => :'deliver_at', + :'custom_fields' => :'custom_fields', + :'delivery' => :'delivery' + } + 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', + :'order_id' => :'String', + :'created_at' => :'Time', + :'value' => :'ListRewards200ResponseRewardsInnerValue', + :'recipient' => :'ListRewards200ResponseRewardsInnerRecipient', + :'deliver_at' => :'Date', + :'custom_fields' => :'Array', + :'delivery' => :'CreateOrder200ResponseOrderRewardsInnerDelivery' + } + 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::CreateOrder200ResponseOrderRewardsInner` 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::CreateOrder200ResponseOrderRewardsInner`. 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?(:'order_id') + self.order_id = attributes[:'order_id'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + end + + if attributes.key?(:'recipient') + self.recipient = attributes[:'recipient'] + end + + if attributes.key?(:'deliver_at') + self.deliver_at = attributes[:'deliver_at'] + end + + if attributes.key?(:'custom_fields') + if (value = attributes[:'custom_fields']).is_a?(Array) + self.custom_fields = value + end + end + + if attributes.key?(:'delivery') + self.delivery = attributes[:'delivery'] + 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 + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !@order_id.nil? && @order_id !~ pattern + invalid_properties.push("invalid value for \"order_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}/) + return false if !@order_id.nil? && @order_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 + + # Custom attribute writer method with validation + # @param [Object] order_id Value to be assigned + def order_id=(order_id) + if order_id.nil? + fail ArgumentError, 'order_id cannot be nil' + end + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if order_id !~ pattern + fail ArgumentError, "invalid value for \"order_id\", must conform to the pattern #{pattern}." + end + + @order_id = order_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 && + order_id == o.order_id && + created_at == o.created_at && + value == o.value && + recipient == o.recipient && + deliver_at == o.deliver_at && + custom_fields == o.custom_fields && + delivery == o.delivery + 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, order_id, created_at, value, recipient, deliver_at, custom_fields, delivery].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_order200_response_order_rewards_inner_delivery.rb b/lib/tremendous/models/create_order200_response_order_rewards_inner_delivery.rb new file mode 100644 index 0000000..dd3c0e8 --- /dev/null +++ b/lib/tremendous/models/create_order200_response_order_rewards_inner_delivery.rb @@ -0,0 +1,296 @@ +=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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # Details on how the reward is delivered to the recipient. + class CreateOrder200ResponseOrderRewardsInnerDelivery + # How to deliver the reward to the recipient.
Delivery Method Description
EMAIL Deliver the reward to the recipient by email
LINK

Deliver the reward to the recipient via a link.

The link can be retrieved on a successfully ordered reward via the /rewards or /rewards/{id} endpoint. That link must then be delivered to the recipient out-of-band.

PHONE Deliver the reward to the recipient by SMS
+ attr_accessor :method + + # Current status of the delivery of the reward: * `SCHEDULED` - Reward is scheduled for delivery and will be delivered soon. * `FAILED` - Delivery of reward failed (e.g. email bounced). * `SUCCEEDED` - Reward was successfully delivered (email or text message delivered or reward link opened). * `PENDING` - Delivery is pending but not yet scheduled. + attr_accessor :status + + # Link to redeem the reward at. You need to deliver this link to the recipient. + attr_accessor :link + + 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 + { + :'method' => :'method', + :'status' => :'status', + :'link' => :'link' + } + 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 + { + :'method' => :'String', + :'status' => :'String', + :'link' => :'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::CreateOrder200ResponseOrderRewardsInnerDelivery` 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::CreateOrder200ResponseOrderRewardsInnerDelivery`. 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?(:'method') + self.method = attributes[:'method'] + else + self.method = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'link') + self.link = attributes[:'link'] + 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 @method.nil? + invalid_properties.push('invalid value for "method", method cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status 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 @method.nil? + method_validator = EnumAttributeValidator.new('String', ["EMAIL", "LINK", "PHONE"]) + return false unless method_validator.valid?(@method) + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "FAILED", "SUCCEEDED", "PENDING"]) + return false unless status_validator.valid?(@status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] method Object to be assigned + def method=(method) + validator = EnumAttributeValidator.new('String', ["EMAIL", "LINK", "PHONE"]) + unless validator.valid?(method) + fail ArgumentError, "invalid value for \"method\", must be one of #{validator.allowable_values}." + end + @method = method + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED", "FAILED", "SUCCEEDED", "PENDING"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + 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 && + method == o.method && + status == o.status && + link == o.link + 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 + [method, status, link].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_order201_response.rb b/lib/tremendous/models/create_order201_response.rb new file mode 100644 index 0000000..01b030c --- /dev/null +++ b/lib/tremendous/models/create_order201_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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + class CreateOrder201Response + attr_accessor :order + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'order' => :'order' + } + 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 + { + :'order' => :'ListOrders200ResponseOrdersInner' + } + 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::CreateOrder201Response` 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::CreateOrder201Response`. 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?(:'order') + self.order = attributes[:'order'] + else + self.order = 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 @order.nil? + invalid_properties.push('invalid value for "order", order 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 @order.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 && + order == o.order + 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 + [order].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_organization.rb b/lib/tremendous/models/create_organization.rb index b0aef4c..568545c 100644 --- a/lib/tremendous/models/create_organization.rb +++ b/lib/tremendous/models/create_organization.rb @@ -15,6 +15,8 @@ module Tremendous class CreateOrganization + attr_accessor :id + # Name of the organization attr_accessor :name @@ -29,14 +31,19 @@ class CreateOrganization # Phone number of the organization. For non-US phone numbers, specify the country code (prefixed with +). attr_accessor :phone + # Timestamp of when the organization has been created. + attr_accessor :created_at + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'id' => :'id', :'name' => :'name', :'website' => :'website', :'with_api_key' => :'with_api_key', :'copy_settings' => :'copy_settings', - :'phone' => :'phone' + :'phone' => :'phone', + :'created_at' => :'created_at' } end @@ -48,11 +55,13 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { + :'id' => :'String', :'name' => :'String', :'website' => :'String', :'with_api_key' => :'Boolean', :'copy_settings' => :'CreateOrganizationRequestCopySettings', - :'phone' => :'String' + :'phone' => :'String', + :'created_at' => :'Date' } end @@ -77,6 +86,10 @@ def initialize(attributes = {}) h[k.to_sym] = v } + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + if attributes.key?(:'name') self.name = attributes[:'name'] else @@ -91,6 +104,8 @@ def initialize(attributes = {}) if attributes.key?(:'with_api_key') self.with_api_key = attributes[:'with_api_key'] + else + self.with_api_key = nil end if attributes.key?(:'copy_settings') @@ -100,6 +115,10 @@ def initialize(attributes = {}) if attributes.key?(:'phone') self.phone = attributes[:'phone'] end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end end # Show invalid properties with the reasons. Usually used together with valid? @@ -107,6 +126,11 @@ def initialize(attributes = {}) 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 + if @name.nil? invalid_properties.push('invalid value for "name", name cannot be nil.') end @@ -115,6 +139,10 @@ def list_invalid_properties invalid_properties.push('invalid value for "website", website cannot be nil.') end + if @with_api_key.nil? + invalid_properties.push('invalid value for "with_api_key", with_api_key cannot be nil.') + end + invalid_properties end @@ -122,21 +150,40 @@ def list_invalid_properties # @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}/) return false if @name.nil? return false if @website.nil? + return false if @with_api_key.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 && name == o.name && website == o.website && with_api_key == o.with_api_key && copy_settings == o.copy_settings && - phone == o.phone + phone == o.phone && + created_at == o.created_at end # @see the `==` method @@ -148,7 +195,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [name, website, with_api_key, copy_settings, phone].hash + [id, name, website, with_api_key, copy_settings, phone, created_at].hash end # Builds the object from hash diff --git a/lib/tremendous/models/create_organization200_response_organization.rb b/lib/tremendous/models/create_organization200_response_organization.rb index 398391e..ab09a1d 100644 --- a/lib/tremendous/models/create_organization200_response_organization.rb +++ b/lib/tremendous/models/create_organization200_response_organization.rb @@ -14,7 +14,6 @@ require 'time' module Tremendous - # Organizations are a way to separate different parts of your business within the same Tremendous account. Your root Tremendous account is an organization itself and can have multiple sub-organizations. You can assign users in your Tremendous team as members to any organization. Users can be members of multiple organizations at once. Each organizations can have it's own API key. class CreateOrganization200ResponseOrganization attr_accessor :id @@ -24,44 +23,25 @@ class CreateOrganization200ResponseOrganization # URL of the website of that organization attr_accessor :website - # Status of the organization. Organizations need to be approved to be able to use them to send out rewards. - attr_accessor :status + attr_accessor :copy_settings - # Timestamp of when the organization has been created. *This field is only returned when creating an organization.* It is not returned anymore when retrieving or listing organizations. + # Phone number of the organization. For non-US phone numbers, specify the country code (prefixed with +). + attr_accessor :phone + + # Timestamp of when the organization has been created. attr_accessor :created_at - # The API key for the created organization. This property is only returned when `with_api_key` is set to `true`. + # The API key for the created organization. This property is only returned when `api_key` is set to `true`. attr_accessor :api_key - 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 { :'id' => :'id', :'name' => :'name', :'website' => :'website', - :'status' => :'status', + :'copy_settings' => :'copy_settings', + :'phone' => :'phone', :'created_at' => :'created_at', :'api_key' => :'api_key' } @@ -78,7 +58,8 @@ def self.openapi_types :'id' => :'String', :'name' => :'String', :'website' => :'String', - :'status' => :'String', + :'copy_settings' => :'CreateOrganizationRequestCopySettings', + :'phone' => :'String', :'created_at' => :'Date', :'api_key' => :'String' } @@ -87,6 +68,7 @@ def self.openapi_types # List of attributes with nullable: true def self.openapi_nullable Set.new([ + :'phone', ]) end @@ -121,8 +103,12 @@ def initialize(attributes = {}) self.website = nil end - if attributes.key?(:'status') - self.status = attributes[:'status'] + if attributes.key?(:'copy_settings') + self.copy_settings = attributes[:'copy_settings'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] end if attributes.key?(:'created_at') @@ -162,8 +148,6 @@ def valid? return false if !@id.nil? && @id !~ Regexp.new(/[A-Z0-9]{4,20}/) return false if @name.nil? return false if @website.nil? - status_validator = EnumAttributeValidator.new('String', ["PENDING", "APPROVED", "REJECTED"]) - return false unless status_validator.valid?(@status) true end @@ -182,16 +166,6 @@ def id=(id) @id = id end - # Custom attribute writer method checking allowed values (enum). - # @param [Object] status Object to be assigned - def status=(status) - validator = EnumAttributeValidator.new('String', ["PENDING", "APPROVED", "REJECTED"]) - unless validator.valid?(status) - fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." - end - @status = status - end - # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) @@ -200,7 +174,8 @@ def ==(o) id == o.id && name == o.name && website == o.website && - status == o.status && + copy_settings == o.copy_settings && + phone == o.phone && created_at == o.created_at && api_key == o.api_key end @@ -214,7 +189,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [id, name, website, status, created_at, api_key].hash + [id, name, website, copy_settings, phone, created_at, api_key].hash end # Builds the object from hash diff --git a/lib/tremendous/models/create_organization_for_response.rb b/lib/tremendous/models/create_organization_for_response.rb new file mode 100644 index 0000000..2241cc2 --- /dev/null +++ b/lib/tremendous/models/create_organization_for_response.rb @@ -0,0 +1,309 @@ +=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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + class CreateOrganizationForResponse + attr_accessor :id + + # Name of the organization + attr_accessor :name + + # URL of the website of that organization + attr_accessor :website + + # Default value is `false`. Set to true to also generate an API key associated to the new organization. + attr_accessor :with_api_key + + attr_accessor :copy_settings + + # Phone number of the organization. For non-US phone numbers, specify the country code (prefixed with +). + attr_accessor :phone + + # Timestamp of when the organization has been created. + attr_accessor :created_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'website' => :'website', + :'with_api_key' => :'with_api_key', + :'copy_settings' => :'copy_settings', + :'phone' => :'phone', + :'created_at' => :'created_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', + :'name' => :'String', + :'website' => :'String', + :'with_api_key' => :'Boolean', + :'copy_settings' => :'CreateOrganizationRequestCopySettings', + :'phone' => :'String', + :'created_at' => :'Date' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'phone', + ]) + 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::CreateOrganizationForResponse` 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::CreateOrganizationForResponse`. 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?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'website') + self.website = attributes[:'website'] + else + self.website = nil + end + + if attributes.key?(:'with_api_key') + self.with_api_key = attributes[:'with_api_key'] + end + + if attributes.key?(:'copy_settings') + self.copy_settings = attributes[:'copy_settings'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_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 + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @website.nil? + invalid_properties.push('invalid value for "website", website 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? && @id !~ Regexp.new(/[A-Z0-9]{4,20}/) + return false if @name.nil? + return false if @website.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 && + name == o.name && + website == o.website && + with_api_key == o.with_api_key && + copy_settings == o.copy_settings && + phone == o.phone && + created_at == o.created_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, name, website, with_api_key, copy_settings, phone, created_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/create_organization_properties.rb b/lib/tremendous/models/create_organization_properties.rb new file mode 100644 index 0000000..880cfbe --- /dev/null +++ b/lib/tremendous/models/create_organization_properties.rb @@ -0,0 +1,294 @@ +=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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + class CreateOrganizationProperties + attr_accessor :id + + # Name of the organization + attr_accessor :name + + # URL of the website of that organization + attr_accessor :website + + # Default value is `false`. Set to true to also generate an API key associated to the new organization. + attr_accessor :with_api_key + + attr_accessor :copy_settings + + # Phone number of the organization. For non-US phone numbers, specify the country code (prefixed with +). + attr_accessor :phone + + # Timestamp of when the organization has been created. + attr_accessor :created_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'website' => :'website', + :'with_api_key' => :'with_api_key', + :'copy_settings' => :'copy_settings', + :'phone' => :'phone', + :'created_at' => :'created_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', + :'name' => :'String', + :'website' => :'String', + :'with_api_key' => :'Boolean', + :'copy_settings' => :'CreateOrganizationRequestCopySettings', + :'phone' => :'String', + :'created_at' => :'Date' + } + 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::CreateOrganizationProperties` 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::CreateOrganizationProperties`. 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?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'website') + self.website = attributes[:'website'] + end + + if attributes.key?(:'with_api_key') + self.with_api_key = attributes[:'with_api_key'] + end + + if attributes.key?(:'copy_settings') + self.copy_settings = attributes[:'copy_settings'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_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 && + name == o.name && + website == o.website && + with_api_key == o.with_api_key && + copy_settings == o.copy_settings && + phone == o.phone && + created_at == o.created_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, name, website, with_api_key, copy_settings, phone, created_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/create_organization_request.rb b/lib/tremendous/models/create_organization_request.rb index f2d0f8b..afba776 100644 --- a/lib/tremendous/models/create_organization_request.rb +++ b/lib/tremendous/models/create_organization_request.rb @@ -91,6 +91,8 @@ def initialize(attributes = {}) if attributes.key?(:'with_api_key') self.with_api_key = attributes[:'with_api_key'] + else + self.with_api_key = nil end if attributes.key?(:'copy_settings') @@ -115,6 +117,10 @@ def list_invalid_properties invalid_properties.push('invalid value for "website", website cannot be nil.') end + if @with_api_key.nil? + invalid_properties.push('invalid value for "with_api_key", with_api_key cannot be nil.') + end + invalid_properties end @@ -124,6 +130,7 @@ def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @name.nil? return false if @website.nil? + return false if @with_api_key.nil? true end diff --git a/lib/tremendous/models/delivery_details.rb b/lib/tremendous/models/delivery_details.rb index 1a1d2f3..beb8f69 100644 --- a/lib/tremendous/models/delivery_details.rb +++ b/lib/tremendous/models/delivery_details.rb @@ -88,14 +88,10 @@ def initialize(attributes = {}) if attributes.key?(:'method') self.method = attributes[:'method'] - else - self.method = nil end if attributes.key?(:'status') self.status = attributes[:'status'] - else - self.status = nil end end @@ -104,14 +100,6 @@ def initialize(attributes = {}) def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new - if @method.nil? - invalid_properties.push('invalid value for "method", method cannot be nil.') - end - - if @status.nil? - invalid_properties.push('invalid value for "status", status cannot be nil.') - end - invalid_properties end @@ -119,10 +107,8 @@ def list_invalid_properties # @return true if the model is valid def valid? warn '[DEPRECATED] the `valid?` method is obsolete' - return false if @method.nil? method_validator = EnumAttributeValidator.new('String', ["EMAIL", "LINK", "PHONE"]) return false unless method_validator.valid?(@method) - return false if @status.nil? status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "FAILED", "SUCCEEDED", "PENDING"]) return false unless status_validator.valid?(@status) true diff --git a/lib/tremendous/models/delivery_details_with_link.rb b/lib/tremendous/models/delivery_details_with_link.rb new file mode 100644 index 0000000..31b78f8 --- /dev/null +++ b/lib/tremendous/models/delivery_details_with_link.rb @@ -0,0 +1,296 @@ +=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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # Details on how the reward is delivered to the recipient. + class DeliveryDetailsWithLink + # How to deliver the reward to the recipient.
Delivery Method Description
EMAIL Deliver the reward to the recipient by email
LINK

Deliver the reward to the recipient via a link.

The link can be retrieved on a successfully ordered reward via the /rewards or /rewards/{id} endpoint. That link must then be delivered to the recipient out-of-band.

PHONE Deliver the reward to the recipient by SMS
+ attr_accessor :method + + # Current status of the delivery of the reward: * `SCHEDULED` - Reward is scheduled for delivery and will be delivered soon. * `FAILED` - Delivery of reward failed (e.g. email bounced). * `SUCCEEDED` - Reward was successfully delivered (email or text message delivered or reward link opened). * `PENDING` - Delivery is pending but not yet scheduled. + attr_accessor :status + + # Link to redeem the reward at. You need to deliver this link to the recipient. + attr_accessor :link + + 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 + { + :'method' => :'method', + :'status' => :'status', + :'link' => :'link' + } + 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 + { + :'method' => :'String', + :'status' => :'String', + :'link' => :'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::DeliveryDetailsWithLink` 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::DeliveryDetailsWithLink`. 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?(:'method') + self.method = attributes[:'method'] + else + self.method = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'link') + self.link = attributes[:'link'] + 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 @method.nil? + invalid_properties.push('invalid value for "method", method cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status 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 @method.nil? + method_validator = EnumAttributeValidator.new('String', ["EMAIL", "LINK", "PHONE"]) + return false unless method_validator.valid?(@method) + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "FAILED", "SUCCEEDED", "PENDING"]) + return false unless status_validator.valid?(@status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] method Object to be assigned + def method=(method) + validator = EnumAttributeValidator.new('String', ["EMAIL", "LINK", "PHONE"]) + unless validator.valid?(method) + fail ArgumentError, "invalid value for \"method\", must be one of #{validator.allowable_values}." + end + @method = method + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED", "FAILED", "SUCCEEDED", "PENDING"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + 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 && + method == o.method && + status == o.status && + link == o.link + 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 + [method, status, link].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/error_model.rb b/lib/tremendous/models/error_model.rb index 49daa39..94c75b9 100644 --- a/lib/tremendous/models/error_model.rb +++ b/lib/tremendous/models/error_model.rb @@ -15,11 +15,15 @@ module Tremendous class ErrorModel + # HTTP status code of the response + attr_accessor :status + attr_accessor :errors # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'status' => :'status', :'errors' => :'errors' } end @@ -32,6 +36,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { + :'status' => :'Integer', :'errors' => :'ListRewards401ResponseErrors' } end @@ -57,6 +62,10 @@ def initialize(attributes = {}) h[k.to_sym] = v } + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + if attributes.key?(:'errors') self.errors = attributes[:'errors'] else @@ -89,6 +98,7 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && + status == o.status && errors == o.errors end @@ -101,7 +111,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [errors].hash + [status, errors].hash end # Builds the object from hash diff --git a/lib/tremendous/models/fraud_rule400_response.rb b/lib/tremendous/models/fraud_rule400_response.rb index 005422e..de2751e 100644 --- a/lib/tremendous/models/fraud_rule400_response.rb +++ b/lib/tremendous/models/fraud_rule400_response.rb @@ -15,11 +15,15 @@ module Tremendous class FraudRule400Response + # HTTP status code of the response + attr_accessor :status + attr_accessor :errors # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'status' => :'status', :'errors' => :'errors' } end @@ -32,6 +36,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { + :'status' => :'Integer', :'errors' => :'ListRewards401ResponseErrors' } end @@ -57,6 +62,10 @@ def initialize(attributes = {}) h[k.to_sym] = v } + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + if attributes.key?(:'errors') self.errors = attributes[:'errors'] else @@ -89,6 +98,7 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && + status == o.status && errors == o.errors end @@ -101,7 +111,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [errors].hash + [status, errors].hash end # Builds the object from hash diff --git a/lib/tremendous/models/fraud_rule422_response.rb b/lib/tremendous/models/fraud_rule422_response.rb index e107b7d..35277e0 100644 --- a/lib/tremendous/models/fraud_rule422_response.rb +++ b/lib/tremendous/models/fraud_rule422_response.rb @@ -15,11 +15,15 @@ module Tremendous class FraudRule422Response + # HTTP status code of the response + attr_accessor :status + attr_accessor :errors # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'status' => :'status', :'errors' => :'errors' } end @@ -32,6 +36,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { + :'status' => :'Integer', :'errors' => :'ListRewards401ResponseErrors' } end @@ -57,6 +62,10 @@ def initialize(attributes = {}) h[k.to_sym] = v } + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + if attributes.key?(:'errors') self.errors = attributes[:'errors'] else @@ -89,6 +98,7 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && + status == o.status && errors == o.errors end @@ -101,7 +111,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [errors].hash + [status, errors].hash end # Builds the object from hash diff --git a/lib/tremendous/models/generate_reward_link403_response.rb b/lib/tremendous/models/generate_reward_link403_response.rb index c76f682..5770078 100644 --- a/lib/tremendous/models/generate_reward_link403_response.rb +++ b/lib/tremendous/models/generate_reward_link403_response.rb @@ -15,11 +15,15 @@ module Tremendous class GenerateRewardLink403Response + # HTTP status code of the response + attr_accessor :status + attr_accessor :errors # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'status' => :'status', :'errors' => :'errors' } end @@ -32,6 +36,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { + :'status' => :'Integer', :'errors' => :'ListRewards401ResponseErrors' } end @@ -57,6 +62,10 @@ def initialize(attributes = {}) h[k.to_sym] = v } + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + if attributes.key?(:'errors') self.errors = attributes[:'errors'] else @@ -89,6 +98,7 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && + status == o.status && errors == o.errors end @@ -101,7 +111,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [errors].hash + [status, errors].hash end # Builds the object from hash diff --git a/lib/tremendous/models/list_rewards200_response_rewards_inner_delivery.rb b/lib/tremendous/models/list_rewards200_response_rewards_inner_delivery.rb index 2d35a6b..163af16 100644 --- a/lib/tremendous/models/list_rewards200_response_rewards_inner_delivery.rb +++ b/lib/tremendous/models/list_rewards200_response_rewards_inner_delivery.rb @@ -88,14 +88,10 @@ def initialize(attributes = {}) if attributes.key?(:'method') self.method = attributes[:'method'] - else - self.method = nil end if attributes.key?(:'status') self.status = attributes[:'status'] - else - self.status = nil end end @@ -104,14 +100,6 @@ def initialize(attributes = {}) def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new - if @method.nil? - invalid_properties.push('invalid value for "method", method cannot be nil.') - end - - if @status.nil? - invalid_properties.push('invalid value for "status", status cannot be nil.') - end - invalid_properties end @@ -119,10 +107,8 @@ def list_invalid_properties # @return true if the model is valid def valid? warn '[DEPRECATED] the `valid?` method is obsolete' - return false if @method.nil? method_validator = EnumAttributeValidator.new('String', ["EMAIL", "LINK", "PHONE"]) return false unless method_validator.valid?(@method) - return false if @status.nil? status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "FAILED", "SUCCEEDED", "PENDING"]) return false unless status_validator.valid?(@status) true diff --git a/lib/tremendous/models/list_rewards401_response.rb b/lib/tremendous/models/list_rewards401_response.rb index 0cc3d08..f42afa7 100644 --- a/lib/tremendous/models/list_rewards401_response.rb +++ b/lib/tremendous/models/list_rewards401_response.rb @@ -15,11 +15,15 @@ module Tremendous class ListRewards401Response + # HTTP status code of the response + attr_accessor :status + attr_accessor :errors # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'status' => :'status', :'errors' => :'errors' } end @@ -32,6 +36,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { + :'status' => :'Integer', :'errors' => :'ListRewards401ResponseErrors' } end @@ -57,6 +62,10 @@ def initialize(attributes = {}) h[k.to_sym] = v } + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + if attributes.key?(:'errors') self.errors = attributes[:'errors'] else @@ -89,6 +98,7 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && + status == o.status && errors == o.errors end @@ -101,7 +111,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [errors].hash + [status, errors].hash end # Builds the object from hash diff --git a/lib/tremendous/models/list_rewards429_response.rb b/lib/tremendous/models/list_rewards429_response.rb index ec4ac8b..e1c9624 100644 --- a/lib/tremendous/models/list_rewards429_response.rb +++ b/lib/tremendous/models/list_rewards429_response.rb @@ -15,11 +15,15 @@ module Tremendous class ListRewards429Response + # HTTP status code of the response + attr_accessor :status + attr_accessor :errors # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'status' => :'status', :'errors' => :'errors' } end @@ -32,6 +36,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { + :'status' => :'Integer', :'errors' => :'ListRewards401ResponseErrors' } end @@ -57,6 +62,10 @@ def initialize(attributes = {}) h[k.to_sym] = v } + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + if attributes.key?(:'errors') self.errors = attributes[:'errors'] else @@ -89,6 +98,7 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && + status == o.status && errors == o.errors end @@ -101,7 +111,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [errors].hash + [status, errors].hash end # Builds the object from hash diff --git a/lib/tremendous/models/order_with_link.rb b/lib/tremendous/models/order_with_link.rb new file mode 100644 index 0000000..a615a24 --- /dev/null +++ b/lib/tremendous/models/order_with_link.rb @@ -0,0 +1,403 @@ +=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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # An order wraps around the fulfilment of one or more rewards. + class OrderWithLink + # Tremendous ID of the order + attr_accessor :id + + # Reference for this order, supplied by the customer. When set, `external_id` makes order idempotent. All requests that use the same `external_id` after the initial order creation, will result in a response that returns the data of the initially created order. The response will have a `201` response code. These responses **fail** to create any further orders. It also allows for retrieving by `external_id` instead of `id` only. + attr_accessor :external_id + + # ID of the campaign in your account, that defines the available products (different gift cards, charity, etc.) that the recipient can choose from. + attr_accessor :campaign_id + + # Date the order has been created + attr_accessor :created_at + + # Execution status of a given order
Status Description
CANCELED The order and all of its rewards were canceled.
CART The order has been created, but hasn't yet been processed.
EXECUTED The order has been executed. Payment has been handled and rewards are being delivered (if applicable).
FAILED The order could not be processed due to an error. E.g. due to insufficient funds in the account.
PENDING APPROVAL The order has been created but needs approval to be executed.
PENDING INTERNAL PAYMENT APPROVAL The order has been created but it is under review and requires approval from our team.
+ attr_accessor :status + + # Name of the channel in which the order was created + attr_accessor :channel + + attr_accessor :payment + + # The ID for the invoice associated with this order + attr_accessor :invoice_id + + attr_accessor :rewards + + 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 + { + :'id' => :'id', + :'external_id' => :'external_id', + :'campaign_id' => :'campaign_id', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'payment' => :'payment', + :'invoice_id' => :'invoice_id', + :'rewards' => :'rewards' + } + 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', + :'external_id' => :'String', + :'campaign_id' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'payment' => :'OrderBasePayment', + :'invoice_id' => :'String', + :'rewards' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'external_id', + :'campaign_id', + ]) + 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::OrderWithLink` 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::OrderWithLink`. 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?(:'external_id') + self.external_id = attributes[:'external_id'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'payment') + self.payment = attributes[:'payment'] + end + + if attributes.key?(:'invoice_id') + self.invoice_id = attributes[:'invoice_id'] + end + + if attributes.key?(:'rewards') + if (value = attributes[:'rewards']).is_a?(Array) + self.rewards = value + end + 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 + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !@campaign_id.nil? && @campaign_id !~ pattern + invalid_properties.push("invalid value for \"campaign_id\", must conform to the pattern #{pattern}.") + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status 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 !@campaign_id.nil? && @campaign_id !~ Regexp.new(/[A-Z0-9]{4,20}/) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["CANCELED", "CART", "EXECUTED", "FAILED", "PENDING APPROVAL", "PENDING INTERNAL PAYMENT APPROVAL"]) + return false unless status_validator.valid?(@status) + channel_validator = EnumAttributeValidator.new('String', ["UI", "API", "EMBED", "DECIPHER", "QUALTRICS", "TYPEFORM", "SURVEY MONKEY"]) + return false unless channel_validator.valid?(@channel) + 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 + + # Custom attribute writer method with validation + # @param [Object] campaign_id Value to be assigned + def campaign_id=(campaign_id) + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !campaign_id.nil? && campaign_id !~ pattern + fail ArgumentError, "invalid value for \"campaign_id\", must conform to the pattern #{pattern}." + end + + @campaign_id = campaign_id + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CANCELED", "CART", "EXECUTED", "FAILED", "PENDING APPROVAL", "PENDING INTERNAL PAYMENT APPROVAL"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] channel Object to be assigned + def channel=(channel) + validator = EnumAttributeValidator.new('String', ["UI", "API", "EMBED", "DECIPHER", "QUALTRICS", "TYPEFORM", "SURVEY MONKEY"]) + unless validator.valid?(channel) + fail ArgumentError, "invalid value for \"channel\", must be one of #{validator.allowable_values}." + end + @channel = channel + 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 && + external_id == o.external_id && + campaign_id == o.campaign_id && + created_at == o.created_at && + status == o.status && + channel == o.channel && + payment == o.payment && + invoice_id == o.invoice_id && + rewards == o.rewards + 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, external_id, campaign_id, created_at, status, channel, payment, invoice_id, rewards].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/order_with_link_rewards_inner.rb b/lib/tremendous/models/order_with_link_rewards_inner.rb new file mode 100644 index 0000000..df4623d --- /dev/null +++ b/lib/tremendous/models/order_with_link_rewards_inner.rb @@ -0,0 +1,385 @@ +=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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # A single reward, sent to a recipient. A reward is always part of an order. Either `products` or `campaign_id` must be specified. + class OrderWithLinkRewardsInner + # Tremendous ID of the reward + attr_accessor :id + + # Tremendous ID of the order this reward is part of. + attr_accessor :order_id + + # Date the reward was created + attr_accessor :created_at + + # ID of the campaign in your account, that defines the available products (different gift cards, charity, etc.) that the recipient can choose from. + attr_accessor :campaign_id + + # List of IDs of product (different gift cards, charity, etc.) that will be available to the recipient to choose from. Providing a `products` array will override the products made available by the campaign specified using the `campaign_id` property unless the `products` array is empty. It will _not_ override other campaign attributes, like the message and customization of the look and feel. + attr_accessor :products + + attr_accessor :value + + attr_accessor :recipient + + # Timestamp of reward delivery within the next year. Note that if date-time is provided, the time values will be ignored. + attr_accessor :deliver_at + + attr_accessor :custom_fields + + attr_accessor :delivery + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'order_id' => :'order_id', + :'created_at' => :'created_at', + :'campaign_id' => :'campaign_id', + :'products' => :'products', + :'value' => :'value', + :'recipient' => :'recipient', + :'deliver_at' => :'deliver_at', + :'custom_fields' => :'custom_fields', + :'delivery' => :'delivery' + } + 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', + :'order_id' => :'String', + :'created_at' => :'Time', + :'campaign_id' => :'String', + :'products' => :'Array', + :'value' => :'ListRewards200ResponseRewardsInnerValue', + :'recipient' => :'ListRewards200ResponseRewardsInnerRecipient', + :'deliver_at' => :'Date', + :'custom_fields' => :'Array', + :'delivery' => :'RewardWithLinkDelivery' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'campaign_id', + ]) + 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::OrderWithLinkRewardsInner` 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::OrderWithLinkRewardsInner`. 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?(:'order_id') + self.order_id = attributes[:'order_id'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'products') + if (value = attributes[:'products']).is_a?(Array) + self.products = value + end + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + end + + if attributes.key?(:'recipient') + self.recipient = attributes[:'recipient'] + end + + if attributes.key?(:'deliver_at') + self.deliver_at = attributes[:'deliver_at'] + end + + if attributes.key?(:'custom_fields') + if (value = attributes[:'custom_fields']).is_a?(Array) + self.custom_fields = value + end + end + + if attributes.key?(:'delivery') + self.delivery = attributes[:'delivery'] + 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 + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !@order_id.nil? && @order_id !~ pattern + invalid_properties.push("invalid value for \"order_id\", must conform to the pattern #{pattern}.") + end + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !@campaign_id.nil? && @campaign_id !~ pattern + invalid_properties.push("invalid value for \"campaign_id\", must conform to the pattern #{pattern}.") + end + + if !@products.nil? && @products.length < 1 + invalid_properties.push('invalid value for "products", number of items must be greater than or equal to 1.') + 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}/) + return false if !@order_id.nil? && @order_id !~ Regexp.new(/[A-Z0-9]{4,20}/) + return false if !@campaign_id.nil? && @campaign_id !~ Regexp.new(/[A-Z0-9]{4,20}/) + return false if !@products.nil? && @products.length < 1 + 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 + + # Custom attribute writer method with validation + # @param [Object] order_id Value to be assigned + def order_id=(order_id) + if order_id.nil? + fail ArgumentError, 'order_id cannot be nil' + end + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if order_id !~ pattern + fail ArgumentError, "invalid value for \"order_id\", must conform to the pattern #{pattern}." + end + + @order_id = order_id + end + + # Custom attribute writer method with validation + # @param [Object] campaign_id Value to be assigned + def campaign_id=(campaign_id) + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !campaign_id.nil? && campaign_id !~ pattern + fail ArgumentError, "invalid value for \"campaign_id\", must conform to the pattern #{pattern}." + end + + @campaign_id = campaign_id + end + + # Custom attribute writer method with validation + # @param [Object] products Value to be assigned + def products=(products) + if products.nil? + fail ArgumentError, 'products cannot be nil' + end + + if products.length < 1 + fail ArgumentError, 'invalid value for "products", number of items must be greater than or equal to 1.' + end + + @products = products + 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 && + order_id == o.order_id && + created_at == o.created_at && + campaign_id == o.campaign_id && + products == o.products && + value == o.value && + recipient == o.recipient && + deliver_at == o.deliver_at && + custom_fields == o.custom_fields && + delivery == o.delivery + 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, order_id, created_at, campaign_id, products, value, recipient, deliver_at, custom_fields, delivery].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/payout.rb b/lib/tremendous/models/payout.rb new file mode 100644 index 0000000..87c77b2 --- /dev/null +++ b/lib/tremendous/models/payout.rb @@ -0,0 +1,340 @@ +=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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + class Payout + # Tremendous ID of the payout + attr_accessor :id + + attr_accessor :status + + # Tremendous ID of the paid out product + attr_accessor :product_id + + # Name of the paid out Product + attr_accessor :product_name + + # Date the payout was created + attr_accessor :created_at + + # Date the payout was executed + attr_accessor :executed_at + + 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 + { + :'id' => :'id', + :'status' => :'status', + :'product_id' => :'product_id', + :'product_name' => :'product_name', + :'created_at' => :'created_at', + :'executed_at' => :'executed_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', + :'status' => :'String', + :'product_id' => :'String', + :'product_name' => :'String', + :'created_at' => :'Time', + :'executed_at' => :'Time' + } + 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::Payout` 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::Payout`. 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?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + end + + if attributes.key?(:'product_name') + self.product_name = attributes[:'product_name'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'executed_at') + self.executed_at = attributes[:'executed_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 + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !@product_id.nil? && @product_id !~ pattern + invalid_properties.push("invalid value for \"product_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}/) + status_validator = EnumAttributeValidator.new('String', ["UNEXECUTED", "COMPLETED", "FAILED", "CANCELED", "ORGANIZATION_REVIEW", "ADMIN_HELD"]) + return false unless status_validator.valid?(@status) + return false if !@product_id.nil? && @product_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 + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["UNEXECUTED", "COMPLETED", "FAILED", "CANCELED", "ORGANIZATION_REVIEW", "ADMIN_HELD"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method with validation + # @param [Object] product_id Value to be assigned + def product_id=(product_id) + if product_id.nil? + fail ArgumentError, 'product_id cannot be nil' + end + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if product_id !~ pattern + fail ArgumentError, "invalid value for \"product_id\", must conform to the pattern #{pattern}." + end + + @product_id = product_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 && + status == o.status && + product_id == o.product_id && + product_name == o.product_name && + created_at == o.created_at && + executed_at == o.executed_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, status, product_id, product_name, created_at, executed_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/resend_reward422_response.rb b/lib/tremendous/models/resend_reward422_response.rb index b6f905e..3e2d610 100644 --- a/lib/tremendous/models/resend_reward422_response.rb +++ b/lib/tremendous/models/resend_reward422_response.rb @@ -15,11 +15,15 @@ module Tremendous class ResendReward422Response + # HTTP status code of the response + attr_accessor :status + attr_accessor :errors # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'status' => :'status', :'errors' => :'errors' } end @@ -32,6 +36,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { + :'status' => :'Integer', :'errors' => :'ListRewards401ResponseErrors' } end @@ -57,6 +62,10 @@ def initialize(attributes = {}) h[k.to_sym] = v } + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + if attributes.key?(:'errors') self.errors = attributes[:'errors'] else @@ -89,6 +98,7 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && + status == o.status && errors == o.errors end @@ -101,7 +111,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [errors].hash + [status, errors].hash end # Builds the object from hash diff --git a/lib/tremendous/models/reward_with_link.rb b/lib/tremendous/models/reward_with_link.rb new file mode 100644 index 0000000..068b07d --- /dev/null +++ b/lib/tremendous/models/reward_with_link.rb @@ -0,0 +1,385 @@ +=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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # A single reward, sent to a recipient. A reward is always part of an order. Either `products` or `campaign_id` must be specified. + class RewardWithLink + # Tremendous ID of the reward + attr_accessor :id + + # Tremendous ID of the order this reward is part of. + attr_accessor :order_id + + # Date the reward was created + attr_accessor :created_at + + # ID of the campaign in your account, that defines the available products (different gift cards, charity, etc.) that the recipient can choose from. + attr_accessor :campaign_id + + # List of IDs of product (different gift cards, charity, etc.) that will be available to the recipient to choose from. Providing a `products` array will override the products made available by the campaign specified using the `campaign_id` property unless the `products` array is empty. It will _not_ override other campaign attributes, like the message and customization of the look and feel. + attr_accessor :products + + attr_accessor :value + + attr_accessor :recipient + + # Timestamp of reward delivery within the next year. Note that if date-time is provided, the time values will be ignored. + attr_accessor :deliver_at + + attr_accessor :custom_fields + + attr_accessor :delivery + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'order_id' => :'order_id', + :'created_at' => :'created_at', + :'campaign_id' => :'campaign_id', + :'products' => :'products', + :'value' => :'value', + :'recipient' => :'recipient', + :'deliver_at' => :'deliver_at', + :'custom_fields' => :'custom_fields', + :'delivery' => :'delivery' + } + 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', + :'order_id' => :'String', + :'created_at' => :'Time', + :'campaign_id' => :'String', + :'products' => :'Array', + :'value' => :'ListRewards200ResponseRewardsInnerValue', + :'recipient' => :'ListRewards200ResponseRewardsInnerRecipient', + :'deliver_at' => :'Date', + :'custom_fields' => :'Array', + :'delivery' => :'RewardWithLinkDelivery' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'campaign_id', + ]) + 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::RewardWithLink` 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::RewardWithLink`. 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?(:'order_id') + self.order_id = attributes[:'order_id'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'products') + if (value = attributes[:'products']).is_a?(Array) + self.products = value + end + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + end + + if attributes.key?(:'recipient') + self.recipient = attributes[:'recipient'] + end + + if attributes.key?(:'deliver_at') + self.deliver_at = attributes[:'deliver_at'] + end + + if attributes.key?(:'custom_fields') + if (value = attributes[:'custom_fields']).is_a?(Array) + self.custom_fields = value + end + end + + if attributes.key?(:'delivery') + self.delivery = attributes[:'delivery'] + 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 + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !@order_id.nil? && @order_id !~ pattern + invalid_properties.push("invalid value for \"order_id\", must conform to the pattern #{pattern}.") + end + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !@campaign_id.nil? && @campaign_id !~ pattern + invalid_properties.push("invalid value for \"campaign_id\", must conform to the pattern #{pattern}.") + end + + if !@products.nil? && @products.length < 1 + invalid_properties.push('invalid value for "products", number of items must be greater than or equal to 1.') + 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}/) + return false if !@order_id.nil? && @order_id !~ Regexp.new(/[A-Z0-9]{4,20}/) + return false if !@campaign_id.nil? && @campaign_id !~ Regexp.new(/[A-Z0-9]{4,20}/) + return false if !@products.nil? && @products.length < 1 + 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 + + # Custom attribute writer method with validation + # @param [Object] order_id Value to be assigned + def order_id=(order_id) + if order_id.nil? + fail ArgumentError, 'order_id cannot be nil' + end + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if order_id !~ pattern + fail ArgumentError, "invalid value for \"order_id\", must conform to the pattern #{pattern}." + end + + @order_id = order_id + end + + # Custom attribute writer method with validation + # @param [Object] campaign_id Value to be assigned + def campaign_id=(campaign_id) + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !campaign_id.nil? && campaign_id !~ pattern + fail ArgumentError, "invalid value for \"campaign_id\", must conform to the pattern #{pattern}." + end + + @campaign_id = campaign_id + end + + # Custom attribute writer method with validation + # @param [Object] products Value to be assigned + def products=(products) + if products.nil? + fail ArgumentError, 'products cannot be nil' + end + + if products.length < 1 + fail ArgumentError, 'invalid value for "products", number of items must be greater than or equal to 1.' + end + + @products = products + 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 && + order_id == o.order_id && + created_at == o.created_at && + campaign_id == o.campaign_id && + products == o.products && + value == o.value && + recipient == o.recipient && + deliver_at == o.deliver_at && + custom_fields == o.custom_fields && + delivery == o.delivery + 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, order_id, created_at, campaign_id, products, value, recipient, deliver_at, custom_fields, delivery].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/reward_with_link_delivery.rb b/lib/tremendous/models/reward_with_link_delivery.rb new file mode 100644 index 0000000..444f15a --- /dev/null +++ b/lib/tremendous/models/reward_with_link_delivery.rb @@ -0,0 +1,296 @@ +=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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # Details on how the reward is delivered to the recipient. + class RewardWithLinkDelivery + # How to deliver the reward to the recipient.
Delivery Method Description
EMAIL Deliver the reward to the recipient by email
LINK

Deliver the reward to the recipient via a link.

The link can be retrieved on a successfully ordered reward via the /rewards or /rewards/{id} endpoint. That link must then be delivered to the recipient out-of-band.

PHONE Deliver the reward to the recipient by SMS
+ attr_accessor :method + + # Current status of the delivery of the reward: * `SCHEDULED` - Reward is scheduled for delivery and will be delivered soon. * `FAILED` - Delivery of reward failed (e.g. email bounced). * `SUCCEEDED` - Reward was successfully delivered (email or text message delivered or reward link opened). * `PENDING` - Delivery is pending but not yet scheduled. + attr_accessor :status + + # Link to redeem the reward at. You need to deliver this link to the recipient. + attr_accessor :link + + 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 + { + :'method' => :'method', + :'status' => :'status', + :'link' => :'link' + } + 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 + { + :'method' => :'String', + :'status' => :'String', + :'link' => :'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::RewardWithLinkDelivery` 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::RewardWithLinkDelivery`. 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?(:'method') + self.method = attributes[:'method'] + else + self.method = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'link') + self.link = attributes[:'link'] + 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 @method.nil? + invalid_properties.push('invalid value for "method", method cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status 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 @method.nil? + method_validator = EnumAttributeValidator.new('String', ["EMAIL", "LINK", "PHONE"]) + return false unless method_validator.valid?(@method) + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "FAILED", "SUCCEEDED", "PENDING"]) + return false unless status_validator.valid?(@status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] method Object to be assigned + def method=(method) + validator = EnumAttributeValidator.new('String', ["EMAIL", "LINK", "PHONE"]) + unless validator.valid?(method) + fail ArgumentError, "invalid value for \"method\", must be one of #{validator.allowable_values}." + end + @method = method + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED", "FAILED", "SUCCEEDED", "PENDING"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + 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 && + method == o.method && + status == o.status && + link == o.link + 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 + [method, status, link].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/reward_without_link_delivery.rb b/lib/tremendous/models/reward_without_link_delivery.rb index f080b91..44085d1 100644 --- a/lib/tremendous/models/reward_without_link_delivery.rb +++ b/lib/tremendous/models/reward_without_link_delivery.rb @@ -88,14 +88,10 @@ def initialize(attributes = {}) if attributes.key?(:'method') self.method = attributes[:'method'] - else - self.method = nil end if attributes.key?(:'status') self.status = attributes[:'status'] - else - self.status = nil end end @@ -104,14 +100,6 @@ def initialize(attributes = {}) def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new - if @method.nil? - invalid_properties.push('invalid value for "method", method cannot be nil.') - end - - if @status.nil? - invalid_properties.push('invalid value for "status", status cannot be nil.') - end - invalid_properties end @@ -119,10 +107,8 @@ def list_invalid_properties # @return true if the model is valid def valid? warn '[DEPRECATED] the `valid?` method is obsolete' - return false if @method.nil? method_validator = EnumAttributeValidator.new('String', ["EMAIL", "LINK", "PHONE"]) return false unless method_validator.valid?(@method) - return false if @status.nil? status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "FAILED", "SUCCEEDED", "PENDING"]) return false unless status_validator.valid?(@status) true diff --git a/lib/tremendous/models/single_reward_order_with_link.rb b/lib/tremendous/models/single_reward_order_with_link.rb new file mode 100644 index 0000000..839d065 --- /dev/null +++ b/lib/tremendous/models/single_reward_order_with_link.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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + class SingleRewardOrderWithLink + attr_accessor :order + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'order' => :'order' + } + 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 + { + :'order' => :'SingleRewardOrderWithLinkOrder' + } + 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::SingleRewardOrderWithLink` 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::SingleRewardOrderWithLink`. 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?(:'order') + self.order = attributes[:'order'] + else + self.order = 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 @order.nil? + invalid_properties.push('invalid value for "order", order 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 @order.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 && + order == o.order + 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 + [order].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/single_reward_order_with_link_order.rb b/lib/tremendous/models/single_reward_order_with_link_order.rb new file mode 100644 index 0000000..622b8ee --- /dev/null +++ b/lib/tremendous/models/single_reward_order_with_link_order.rb @@ -0,0 +1,403 @@ +=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 +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # An order wraps around the fulfilment of one or more rewards. + class SingleRewardOrderWithLinkOrder + # Tremendous ID of the order + attr_accessor :id + + # Reference for this order, supplied by the customer. When set, `external_id` makes order idempotent. All requests that use the same `external_id` after the initial order creation, will result in a response that returns the data of the initially created order. The response will have a `201` response code. These responses **fail** to create any further orders. It also allows for retrieving by `external_id` instead of `id` only. + attr_accessor :external_id + + # ID of the campaign in your account, that defines the available products (different gift cards, charity, etc.) that the recipient can choose from. + attr_accessor :campaign_id + + # Date the order has been created + attr_accessor :created_at + + # Execution status of a given order
Status Description
CANCELED The order and all of its rewards were canceled.
CART The order has been created, but hasn't yet been processed.
EXECUTED The order has been executed. Payment has been handled and rewards are being delivered (if applicable).
FAILED The order could not be processed due to an error. E.g. due to insufficient funds in the account.
PENDING APPROVAL The order has been created but needs approval to be executed.
PENDING INTERNAL PAYMENT APPROVAL The order has been created but it is under review and requires approval from our team.
+ attr_accessor :status + + # Name of the channel in which the order was created + attr_accessor :channel + + attr_accessor :payment + + # The ID for the invoice associated with this order + attr_accessor :invoice_id + + attr_accessor :rewards + + 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 + { + :'id' => :'id', + :'external_id' => :'external_id', + :'campaign_id' => :'campaign_id', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'payment' => :'payment', + :'invoice_id' => :'invoice_id', + :'rewards' => :'rewards' + } + 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', + :'external_id' => :'String', + :'campaign_id' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'payment' => :'OrderBasePayment', + :'invoice_id' => :'String', + :'rewards' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'external_id', + :'campaign_id', + ]) + 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::SingleRewardOrderWithLinkOrder` 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::SingleRewardOrderWithLinkOrder`. 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?(:'external_id') + self.external_id = attributes[:'external_id'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'payment') + self.payment = attributes[:'payment'] + end + + if attributes.key?(:'invoice_id') + self.invoice_id = attributes[:'invoice_id'] + end + + if attributes.key?(:'rewards') + if (value = attributes[:'rewards']).is_a?(Array) + self.rewards = value + end + 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 + + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !@campaign_id.nil? && @campaign_id !~ pattern + invalid_properties.push("invalid value for \"campaign_id\", must conform to the pattern #{pattern}.") + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status 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 !@campaign_id.nil? && @campaign_id !~ Regexp.new(/[A-Z0-9]{4,20}/) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["CANCELED", "CART", "EXECUTED", "FAILED", "PENDING APPROVAL", "PENDING INTERNAL PAYMENT APPROVAL"]) + return false unless status_validator.valid?(@status) + channel_validator = EnumAttributeValidator.new('String', ["UI", "API", "EMBED", "DECIPHER", "QUALTRICS", "TYPEFORM", "SURVEY MONKEY"]) + return false unless channel_validator.valid?(@channel) + 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 + + # Custom attribute writer method with validation + # @param [Object] campaign_id Value to be assigned + def campaign_id=(campaign_id) + pattern = Regexp.new(/[A-Z0-9]{4,20}/) + if !campaign_id.nil? && campaign_id !~ pattern + fail ArgumentError, "invalid value for \"campaign_id\", must conform to the pattern #{pattern}." + end + + @campaign_id = campaign_id + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CANCELED", "CART", "EXECUTED", "FAILED", "PENDING APPROVAL", "PENDING INTERNAL PAYMENT APPROVAL"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] channel Object to be assigned + def channel=(channel) + validator = EnumAttributeValidator.new('String', ["UI", "API", "EMBED", "DECIPHER", "QUALTRICS", "TYPEFORM", "SURVEY MONKEY"]) + unless validator.valid?(channel) + fail ArgumentError, "invalid value for \"channel\", must be one of #{validator.allowable_values}." + end + @channel = channel + 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 && + external_id == o.external_id && + campaign_id == o.campaign_id && + created_at == o.created_at && + status == o.status && + channel == o.channel && + payment == o.payment && + invoice_id == o.invoice_id && + rewards == o.rewards + 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, external_id, campaign_id, created_at, status, channel, payment, invoice_id, rewards].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