diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index d3c6034..9c1877d 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -5,6 +5,7 @@ lib/tremendous/api_error.rb lib/tremendous/configuration.rb lib/tremendous/models/balance_transaction.rb lib/tremendous/models/campaign.rb +lib/tremendous/models/campaign_base.rb lib/tremendous/models/create_api_key200_response.rb lib/tremendous/models/create_campaign201_response.rb lib/tremendous/models/create_campaign_request.rb @@ -61,6 +62,7 @@ lib/tremendous/models/list_campaigns200_response_campaigns_inner_email_style.rb lib/tremendous/models/list_campaigns200_response_campaigns_inner_webpage_style.rb lib/tremendous/models/list_fields200_response.rb lib/tremendous/models/list_fields200_response_fields_inner.rb +lib/tremendous/models/list_forex_response.rb lib/tremendous/models/list_funding_sources200_response.rb lib/tremendous/models/list_funding_sources200_response_funding_sources_inner.rb lib/tremendous/models/list_funding_sources200_response_funding_sources_inner_meta.rb @@ -124,5 +126,7 @@ 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/simulate_webhook_request.rb +lib/tremendous/models/update_campaign.rb +lib/tremendous/models/update_campaign_request.rb lib/tremendous/models/webhook.rb lib/tremendous/models/webhook_post.rb diff --git a/Gemfile.lock b/Gemfile.lock index 5d9972f..eadffe7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tremendous_ruby (5.1.0) + tremendous_ruby (5.2.0) faraday (>= 1.0.1, < 3.0) faraday-multipart diff --git a/lib/tremendous.rb b/lib/tremendous.rb index 05ac0e0..1d68c4a 100644 --- a/lib/tremendous.rb +++ b/lib/tremendous.rb @@ -19,6 +19,7 @@ # Models require 'tremendous/models/balance_transaction' require 'tremendous/models/campaign' +require 'tremendous/models/campaign_base' require 'tremendous/models/create_api_key200_response' require 'tremendous/models/create_campaign201_response' require 'tremendous/models/create_campaign_request' @@ -75,6 +76,7 @@ require 'tremendous/models/list_campaigns200_response_campaigns_inner_webpage_style' require 'tremendous/models/list_fields200_response' require 'tremendous/models/list_fields200_response_fields_inner' +require 'tremendous/models/list_forex_response' require 'tremendous/models/list_funding_sources200_response' require 'tremendous/models/list_funding_sources200_response_funding_sources_inner' require 'tremendous/models/list_funding_sources200_response_funding_sources_inner_meta' @@ -138,6 +140,8 @@ require 'tremendous/models/reward_without_link' require 'tremendous/models/reward_without_link_delivery' require 'tremendous/models/simulate_webhook_request' +require 'tremendous/models/update_campaign' +require 'tremendous/models/update_campaign_request' require 'tremendous/models/webhook' require 'tremendous/models/webhook_post' diff --git a/lib/tremendous/api/tremendous_api.rb b/lib/tremendous/api/tremendous_api.rb index c7e1eb2..93e0bc7 100644 --- a/lib/tremendous/api/tremendous_api.rb +++ b/lib/tremendous/api/tremendous_api.rb @@ -1656,6 +1656,66 @@ def list_fields_with_http_info(opts = {}) return data, status_code, headers end + # List exchange rates + # Retrieve a list of exchange rates + # @param [Hash] opts the optional parameters + # @option opts [String] :base Base currency code, default is USD. + # @return [ListForexResponse] + def list_forex(opts = {}) + data, _status_code, _headers = list_forex_with_http_info(opts) + data + end + + # List exchange rates + # Retrieve a list of exchange rates + # @param [Hash] opts the optional parameters + # @option opts [String] :base Base currency code, default is USD. + # @return [Array<(ListForexResponse, Integer, Hash)>] ListForexResponse data, response status code and response headers + def list_forex_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TremendousApi.list_forex ...' + end + # resource path + local_var_path = '/forex' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'base'] = opts[:'base'] if !opts[:'base'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ListForexResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['BearerApiKey'] + + new_options = opts.merge( + :operation => :"TremendousApi.list_forex", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TremendousApi#list_forex\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # List funding sources # Retrieve a list of all funding sources available for ordering through the API in your organization's account. # @param [Hash] opts the optional parameters @@ -2430,20 +2490,20 @@ def simulate_webhook_with_http_info(id, simulate_webhook_request, opts = {}) # Update campaign # @param id [String] ID of the campaign that should be updated - # @param create_campaign_request [CreateCampaignRequest] Campaign details + # @param update_campaign_request [UpdateCampaignRequest] Campaign details # @param [Hash] opts the optional parameters # @return [CreateCampaign201Response] - def update_campaign(id, create_campaign_request, opts = {}) - data, _status_code, _headers = update_campaign_with_http_info(id, create_campaign_request, opts) + def update_campaign(id, update_campaign_request, opts = {}) + data, _status_code, _headers = update_campaign_with_http_info(id, update_campaign_request, opts) data end # Update campaign # @param id [String] ID of the campaign that should be updated - # @param create_campaign_request [CreateCampaignRequest] Campaign details + # @param update_campaign_request [UpdateCampaignRequest] Campaign details # @param [Hash] opts the optional parameters # @return [Array<(CreateCampaign201Response, Integer, Hash)>] CreateCampaign201Response data, response status code and response headers - def update_campaign_with_http_info(id, create_campaign_request, opts = {}) + def update_campaign_with_http_info(id, update_campaign_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TremendousApi.update_campaign ...' end @@ -2456,9 +2516,9 @@ def update_campaign_with_http_info(id, create_campaign_request, opts = {}) fail ArgumentError, "invalid value for 'id' when calling TremendousApi.update_campaign, must conform to the pattern #{pattern}." end - # verify the required parameter 'create_campaign_request' is set - if @api_client.config.client_side_validation && create_campaign_request.nil? - fail ArgumentError, "Missing the required parameter 'create_campaign_request' when calling TremendousApi.update_campaign" + # verify the required parameter 'update_campaign_request' is set + if @api_client.config.client_side_validation && update_campaign_request.nil? + fail ArgumentError, "Missing the required parameter 'update_campaign_request' when calling TremendousApi.update_campaign" end # resource path local_var_path = '/campaigns/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) @@ -2480,7 +2540,7 @@ def update_campaign_with_http_info(id, create_campaign_request, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:debug_body] || @api_client.object_to_http_body(create_campaign_request) + post_body = opts[:debug_body] || @api_client.object_to_http_body(update_campaign_request) # return_type return_type = opts[:debug_return_type] || 'CreateCampaign201Response' diff --git a/lib/tremendous/models/campaign_base.rb b/lib/tremendous/models/campaign_base.rb new file mode 100644 index 0000000..b74187e --- /dev/null +++ b/lib/tremendous/models/campaign_base.rb @@ -0,0 +1,287 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # With a campaign you can define the look & feel of how rewards are sent out. It also lets you set the available products (different gift cards, charity, etc.) recipients can choose from. + class CampaignBase + attr_accessor :id + + # Name of the campaign + attr_accessor :name + + # Description of the campaign + attr_accessor :description + + # List of IDs of products (different gift cards, charity, etc.) that are available in this campaign. + attr_accessor :products + + attr_accessor :webpage_style + + attr_accessor :email_style + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'description' => :'description', + :'products' => :'products', + :'webpage_style' => :'webpage_style', + :'email_style' => :'email_style' + } + 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', + :'description' => :'String', + :'products' => :'Array', + :'webpage_style' => :'ListCampaigns200ResponseCampaignsInnerWebpageStyle', + :'email_style' => :'ListCampaigns200ResponseCampaignsInnerEmailStyle' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'description', + ]) + 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::CampaignBase` 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::CampaignBase`. 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?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'products') + if (value = attributes[:'products']).is_a?(Array) + self.products = value + end + end + + if attributes.key?(:'webpage_style') + self.webpage_style = attributes[:'webpage_style'] + end + + if attributes.key?(:'email_style') + self.email_style = attributes[:'email_style'] + 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 && + description == o.description && + products == o.products && + webpage_style == o.webpage_style && + email_style == o.email_style + 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, description, products, webpage_style, email_style].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Tremendous.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/tremendous/models/list_forex_response.rb b/lib/tremendous/models/list_forex_response.rb new file mode 100644 index 0000000..13f2821 --- /dev/null +++ b/lib/tremendous/models/list_forex_response.rb @@ -0,0 +1,223 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + class ListForexResponse + attr_accessor :forex + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'forex' => :'forex' + } + 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 + { + :'forex' => :'Hash' + } + 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::ListForexResponse` 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::ListForexResponse`. 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?(:'forex') + if (value = attributes[:'forex']).is_a?(Hash) + self.forex = value + end + else + self.forex = 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 @forex.nil? + invalid_properties.push('invalid value for "forex", forex 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 @forex.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 && + forex == o.forex + 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 + [forex].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/update_campaign.rb b/lib/tremendous/models/update_campaign.rb new file mode 100644 index 0000000..bcd4d07 --- /dev/null +++ b/lib/tremendous/models/update_campaign.rb @@ -0,0 +1,287 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # With a campaign you can define the look & feel of how rewards are sent out. It also lets you set the available products (different gift cards, charity, etc.) recipients can choose from. + class UpdateCampaign + attr_accessor :id + + # Name of the campaign + attr_accessor :name + + # Description of the campaign + attr_accessor :description + + # List of IDs of products (different gift cards, charity, etc.) that are available in this campaign. + attr_accessor :products + + attr_accessor :webpage_style + + attr_accessor :email_style + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'description' => :'description', + :'products' => :'products', + :'webpage_style' => :'webpage_style', + :'email_style' => :'email_style' + } + 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', + :'description' => :'String', + :'products' => :'Array', + :'webpage_style' => :'ListCampaigns200ResponseCampaignsInnerWebpageStyle', + :'email_style' => :'ListCampaigns200ResponseCampaignsInnerEmailStyle' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'description', + ]) + 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::UpdateCampaign` 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::UpdateCampaign`. 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?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'products') + if (value = attributes[:'products']).is_a?(Array) + self.products = value + end + end + + if attributes.key?(:'webpage_style') + self.webpage_style = attributes[:'webpage_style'] + end + + if attributes.key?(:'email_style') + self.email_style = attributes[:'email_style'] + 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 && + description == o.description && + products == o.products && + webpage_style == o.webpage_style && + email_style == o.email_style + 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, description, products, webpage_style, email_style].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/update_campaign_request.rb b/lib/tremendous/models/update_campaign_request.rb new file mode 100644 index 0000000..072f4a0 --- /dev/null +++ b/lib/tremendous/models/update_campaign_request.rb @@ -0,0 +1,257 @@ +=begin +#API Endpoints + +#Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + +The version of the OpenAPI document: 2 +Contact: developers@tremendous.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.3.0 + +=end + +require 'date' +require 'time' + +module Tremendous + # With a campaign you can define the look & feel of how rewards are sent out. It also lets you set the available products (different gift cards, charity, etc.) recipients can choose from. + class UpdateCampaignRequest + # Name of the campaign + attr_accessor :name + + # Description of the campaign + attr_accessor :description + + # List of IDs of products (different gift cards, charity, etc.) that are available in this campaign. + attr_accessor :products + + attr_accessor :webpage_style + + attr_accessor :email_style + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'description' => :'description', + :'products' => :'products', + :'webpage_style' => :'webpage_style', + :'email_style' => :'email_style' + } + 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 + { + :'name' => :'String', + :'description' => :'String', + :'products' => :'Array', + :'webpage_style' => :'ListCampaigns200ResponseCampaignsInnerWebpageStyle', + :'email_style' => :'ListCampaigns200ResponseCampaignsInnerEmailStyle' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'description', + ]) + 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::UpdateCampaignRequest` 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::UpdateCampaignRequest`. 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?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'products') + if (value = attributes[:'products']).is_a?(Array) + self.products = value + end + end + + if attributes.key?(:'webpage_style') + self.webpage_style = attributes[:'webpage_style'] + end + + if attributes.key?(:'email_style') + self.email_style = attributes[:'email_style'] + 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 + 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' + 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 && + name == o.name && + description == o.description && + products == o.products && + webpage_style == o.webpage_style && + email_style == o.email_style + 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 + [name, description, products, webpage_style, email_style].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Tremendous.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/tremendous/version.rb b/lib/tremendous/version.rb index c8e8a4c..62dca0c 100644 --- a/lib/tremendous/version.rb +++ b/lib/tremendous/version.rb @@ -1,3 +1,3 @@ module Tremendous - VERSION = "5.1.0" + VERSION = "5.2.0" end