=begin #Subskribe API #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) OpenAPI spec version: 1.0.0 Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 2.4.41 =end require 'date' module SubskribeDevClient class OrderJson attr_accessor :id attr_accessor :entity_id attr_accessor :external_id attr_accessor :name attr_accessor :account_id attr_accessor :order_type attr_accessor :currency attr_accessor :payment_term attr_accessor :subscription_id attr_accessor :subscription_target_version attr_accessor :shipping_contact_id attr_accessor :billing_contact_id attr_accessor :predefined_discounts attr_accessor :line_items attr_accessor :line_items_net_effect attr_accessor :start_date attr_accessor :end_date attr_accessor :term_length attr_accessor :billing_cycle attr_accessor :billing_term attr_accessor :billing_anchor_date attr_accessor :total_amount attr_accessor :total_list_amount attr_accessor :total_list_amount_before_override attr_accessor :tax_estimate attr_accessor :status attr_accessor :executed_on attr_accessor :updated_on attr_accessor :executed_on_formatted attr_accessor :ramp_interval attr_accessor :order_form_template_ids attr_accessor :order_terms attr_accessor :sfdc_opportunity_id attr_accessor :is_primary_order_for_sfdc_opportunity attr_accessor :sfdc_opportunity_name attr_accessor :sfdc_opportunity_type attr_accessor :sfdc_opportunity_stage attr_accessor :sfdc_order_can_be_executed attr_accessor :opportunity_crm_type attr_accessor :renewal_for_subscription_id attr_accessor :renewal_for_subscription_version attr_accessor :owner_id attr_accessor :document_master_template_id attr_accessor :purchase_order_number attr_accessor :purchase_order_required_for_invoicing attr_accessor :auto_renew attr_accessor :approval_segment_id attr_accessor :attachment_id attr_accessor :composite_order_id attr_accessor :expires_on attr_accessor :custom_fields attr_accessor :start_date_type 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', :'entity_id' => :'entityId', :'external_id' => :'externalId', :'name' => :'name', :'account_id' => :'accountId', :'order_type' => :'orderType', :'currency' => :'currency', :'payment_term' => :'paymentTerm', :'subscription_id' => :'subscriptionId', :'subscription_target_version' => :'subscriptionTargetVersion', :'shipping_contact_id' => :'shippingContactId', :'billing_contact_id' => :'billingContactId', :'predefined_discounts' => :'predefinedDiscounts', :'line_items' => :'lineItems', :'line_items_net_effect' => :'lineItemsNetEffect', :'start_date' => :'startDate', :'end_date' => :'endDate', :'term_length' => :'termLength', :'billing_cycle' => :'billingCycle', :'billing_term' => :'billingTerm', :'billing_anchor_date' => :'billingAnchorDate', :'total_amount' => :'totalAmount', :'total_list_amount' => :'totalListAmount', :'total_list_amount_before_override' => :'totalListAmountBeforeOverride', :'tax_estimate' => :'taxEstimate', :'status' => :'status', :'executed_on' => :'executedOn', :'updated_on' => :'updatedOn', :'executed_on_formatted' => :'executedOnFormatted', :'ramp_interval' => :'rampInterval', :'order_form_template_ids' => :'orderFormTemplateIds', :'order_terms' => :'orderTerms', :'sfdc_opportunity_id' => :'sfdcOpportunityId', :'is_primary_order_for_sfdc_opportunity' => :'isPrimaryOrderForSfdcOpportunity', :'sfdc_opportunity_name' => :'sfdcOpportunityName', :'sfdc_opportunity_type' => :'sfdcOpportunityType', :'sfdc_opportunity_stage' => :'sfdcOpportunityStage', :'sfdc_order_can_be_executed' => :'sfdcOrderCanBeExecuted', :'opportunity_crm_type' => :'opportunityCrmType', :'renewal_for_subscription_id' => :'renewalForSubscriptionId', :'renewal_for_subscription_version' => :'renewalForSubscriptionVersion', :'owner_id' => :'ownerId', :'document_master_template_id' => :'documentMasterTemplateId', :'purchase_order_number' => :'purchaseOrderNumber', :'purchase_order_required_for_invoicing' => :'purchaseOrderRequiredForInvoicing', :'auto_renew' => :'autoRenew', :'approval_segment_id' => :'approvalSegmentId', :'attachment_id' => :'attachmentId', :'composite_order_id' => :'compositeOrderId', :'expires_on' => :'expiresOn', :'custom_fields' => :'customFields', :'start_date_type' => :'startDateType' } end # Attribute type mapping. def self.swagger_types { :'id' => :'String', :'entity_id' => :'String', :'external_id' => :'String', :'name' => :'String', :'account_id' => :'String', :'order_type' => :'String', :'currency' => :'String', :'payment_term' => :'String', :'subscription_id' => :'String', :'subscription_target_version' => :'Integer', :'shipping_contact_id' => :'String', :'billing_contact_id' => :'String', :'predefined_discounts' => :'Array', :'line_items' => :'Array', :'line_items_net_effect' => :'Array', :'start_date' => :'Integer', :'end_date' => :'Integer', :'term_length' => :'RecurrenceJson', :'billing_cycle' => :'RecurrenceJson', :'billing_term' => :'String', :'billing_anchor_date' => :'Integer', :'total_amount' => :'Float', :'total_list_amount' => :'Float', :'total_list_amount_before_override' => :'Float', :'tax_estimate' => :'Float', :'status' => :'String', :'executed_on' => :'Integer', :'updated_on' => :'Integer', :'executed_on_formatted' => :'String', :'ramp_interval' => :'Array', :'order_form_template_ids' => :'Array', :'order_terms' => :'Array', :'sfdc_opportunity_id' => :'String', :'is_primary_order_for_sfdc_opportunity' => :'BOOLEAN', :'sfdc_opportunity_name' => :'String', :'sfdc_opportunity_type' => :'String', :'sfdc_opportunity_stage' => :'String', :'sfdc_order_can_be_executed' => :'BOOLEAN', :'opportunity_crm_type' => :'String', :'renewal_for_subscription_id' => :'String', :'renewal_for_subscription_version' => :'Integer', :'owner_id' => :'String', :'document_master_template_id' => :'String', :'purchase_order_number' => :'String', :'purchase_order_required_for_invoicing' => :'BOOLEAN', :'auto_renew' => :'BOOLEAN', :'approval_segment_id' => :'String', :'attachment_id' => :'String', :'composite_order_id' => :'String', :'expires_on' => :'Integer', :'custom_fields' => :'Array', :'start_date_type' => :'String' } end # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if attributes.has_key?(:'id') self.id = attributes[:'id'] end if attributes.has_key?(:'entityId') self.entity_id = attributes[:'entityId'] end if attributes.has_key?(:'externalId') self.external_id = attributes[:'externalId'] end if attributes.has_key?(:'name') self.name = attributes[:'name'] end if attributes.has_key?(:'accountId') self.account_id = attributes[:'accountId'] end if attributes.has_key?(:'orderType') self.order_type = attributes[:'orderType'] end if attributes.has_key?(:'currency') self.currency = attributes[:'currency'] end if attributes.has_key?(:'paymentTerm') self.payment_term = attributes[:'paymentTerm'] end if attributes.has_key?(:'subscriptionId') self.subscription_id = attributes[:'subscriptionId'] end if attributes.has_key?(:'subscriptionTargetVersion') self.subscription_target_version = attributes[:'subscriptionTargetVersion'] end if attributes.has_key?(:'shippingContactId') self.shipping_contact_id = attributes[:'shippingContactId'] end if attributes.has_key?(:'billingContactId') self.billing_contact_id = attributes[:'billingContactId'] end if attributes.has_key?(:'predefinedDiscounts') if (value = attributes[:'predefinedDiscounts']).is_a?(Array) self.predefined_discounts = value end end if attributes.has_key?(:'lineItems') if (value = attributes[:'lineItems']).is_a?(Array) self.line_items = value end end if attributes.has_key?(:'lineItemsNetEffect') if (value = attributes[:'lineItemsNetEffect']).is_a?(Array) self.line_items_net_effect = value end end if attributes.has_key?(:'startDate') self.start_date = attributes[:'startDate'] end if attributes.has_key?(:'endDate') self.end_date = attributes[:'endDate'] end if attributes.has_key?(:'termLength') self.term_length = attributes[:'termLength'] end if attributes.has_key?(:'billingCycle') self.billing_cycle = attributes[:'billingCycle'] end if attributes.has_key?(:'billingTerm') self.billing_term = attributes[:'billingTerm'] end if attributes.has_key?(:'billingAnchorDate') self.billing_anchor_date = attributes[:'billingAnchorDate'] end if attributes.has_key?(:'totalAmount') self.total_amount = attributes[:'totalAmount'] end if attributes.has_key?(:'totalListAmount') self.total_list_amount = attributes[:'totalListAmount'] end if attributes.has_key?(:'totalListAmountBeforeOverride') self.total_list_amount_before_override = attributes[:'totalListAmountBeforeOverride'] end if attributes.has_key?(:'taxEstimate') self.tax_estimate = attributes[:'taxEstimate'] end if attributes.has_key?(:'status') self.status = attributes[:'status'] end if attributes.has_key?(:'executedOn') self.executed_on = attributes[:'executedOn'] end if attributes.has_key?(:'updatedOn') self.updated_on = attributes[:'updatedOn'] end if attributes.has_key?(:'executedOnFormatted') self.executed_on_formatted = attributes[:'executedOnFormatted'] end if attributes.has_key?(:'rampInterval') if (value = attributes[:'rampInterval']).is_a?(Array) self.ramp_interval = value end end if attributes.has_key?(:'orderFormTemplateIds') if (value = attributes[:'orderFormTemplateIds']).is_a?(Array) self.order_form_template_ids = value end end if attributes.has_key?(:'orderTerms') if (value = attributes[:'orderTerms']).is_a?(Array) self.order_terms = value end end if attributes.has_key?(:'sfdcOpportunityId') self.sfdc_opportunity_id = attributes[:'sfdcOpportunityId'] end if attributes.has_key?(:'isPrimaryOrderForSfdcOpportunity') self.is_primary_order_for_sfdc_opportunity = attributes[:'isPrimaryOrderForSfdcOpportunity'] end if attributes.has_key?(:'sfdcOpportunityName') self.sfdc_opportunity_name = attributes[:'sfdcOpportunityName'] end if attributes.has_key?(:'sfdcOpportunityType') self.sfdc_opportunity_type = attributes[:'sfdcOpportunityType'] end if attributes.has_key?(:'sfdcOpportunityStage') self.sfdc_opportunity_stage = attributes[:'sfdcOpportunityStage'] end if attributes.has_key?(:'sfdcOrderCanBeExecuted') self.sfdc_order_can_be_executed = attributes[:'sfdcOrderCanBeExecuted'] end if attributes.has_key?(:'opportunityCrmType') self.opportunity_crm_type = attributes[:'opportunityCrmType'] end if attributes.has_key?(:'renewalForSubscriptionId') self.renewal_for_subscription_id = attributes[:'renewalForSubscriptionId'] end if attributes.has_key?(:'renewalForSubscriptionVersion') self.renewal_for_subscription_version = attributes[:'renewalForSubscriptionVersion'] end if attributes.has_key?(:'ownerId') self.owner_id = attributes[:'ownerId'] end if attributes.has_key?(:'documentMasterTemplateId') self.document_master_template_id = attributes[:'documentMasterTemplateId'] end if attributes.has_key?(:'purchaseOrderNumber') self.purchase_order_number = attributes[:'purchaseOrderNumber'] end if attributes.has_key?(:'purchaseOrderRequiredForInvoicing') self.purchase_order_required_for_invoicing = attributes[:'purchaseOrderRequiredForInvoicing'] end if attributes.has_key?(:'autoRenew') self.auto_renew = attributes[:'autoRenew'] end if attributes.has_key?(:'approvalSegmentId') self.approval_segment_id = attributes[:'approvalSegmentId'] end if attributes.has_key?(:'attachmentId') self.attachment_id = attributes[:'attachmentId'] end if attributes.has_key?(:'compositeOrderId') self.composite_order_id = attributes[:'compositeOrderId'] end if attributes.has_key?(:'expiresOn') self.expires_on = attributes[:'expiresOn'] end if attributes.has_key?(:'customFields') if (value = attributes[:'customFields']).is_a?(Array) self.custom_fields = value end end if attributes.has_key?(:'startDateType') self.start_date_type = attributes[:'startDateType'] 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 invalid_properties = Array.new if @order_type.nil? invalid_properties.push('invalid value for "order_type", order_type cannot be nil.') end if @start_date.nil? invalid_properties.push('invalid value for "start_date", start_date 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? return false if @order_type.nil? order_type_validator = EnumAttributeValidator.new('String', ['NEW', 'AMENDMENT', 'CANCEL', 'RENEWAL', 'RESTRUCTURE']) return false unless order_type_validator.valid?(@order_type) return false if @start_date.nil? billing_term_validator = EnumAttributeValidator.new('String', ['UP_FRONT', 'IN_ARREARS']) return false unless billing_term_validator.valid?(@billing_term) return false if @status.nil? status_validator = EnumAttributeValidator.new('String', ['DRAFT', 'SUBMITTED', 'APPROVED', 'EXECUTED', 'CANCELLED', 'EXPIRED']) return false unless status_validator.valid?(@status) opportunity_crm_type_validator = EnumAttributeValidator.new('String', ['SALESFORCE', 'HUBSPOT']) return false unless opportunity_crm_type_validator.valid?(@opportunity_crm_type) start_date_type_validator = EnumAttributeValidator.new('String', ['FIXED', 'EXECUTION_DATE']) return false unless start_date_type_validator.valid?(@start_date_type) true end # Custom attribute writer method checking allowed values (enum). # @param [Object] order_type Object to be assigned def order_type=(order_type) validator = EnumAttributeValidator.new('String', ['NEW', 'AMENDMENT', 'CANCEL', 'RENEWAL', 'RESTRUCTURE']) unless validator.valid?(order_type) fail ArgumentError, 'invalid value for "order_type", must be one of #{validator.allowable_values}.' end @order_type = order_type end # Custom attribute writer method checking allowed values (enum). # @param [Object] billing_term Object to be assigned def billing_term=(billing_term) validator = EnumAttributeValidator.new('String', ['UP_FRONT', 'IN_ARREARS']) unless validator.valid?(billing_term) fail ArgumentError, 'invalid value for "billing_term", must be one of #{validator.allowable_values}.' end @billing_term = billing_term end # Custom attribute writer method checking allowed values (enum). # @param [Object] status Object to be assigned def status=(status) validator = EnumAttributeValidator.new('String', ['DRAFT', 'SUBMITTED', 'APPROVED', 'EXECUTED', 'CANCELLED', 'EXPIRED']) 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] opportunity_crm_type Object to be assigned def opportunity_crm_type=(opportunity_crm_type) validator = EnumAttributeValidator.new('String', ['SALESFORCE', 'HUBSPOT']) unless validator.valid?(opportunity_crm_type) fail ArgumentError, 'invalid value for "opportunity_crm_type", must be one of #{validator.allowable_values}.' end @opportunity_crm_type = opportunity_crm_type end # Custom attribute writer method checking allowed values (enum). # @param [Object] start_date_type Object to be assigned def start_date_type=(start_date_type) validator = EnumAttributeValidator.new('String', ['FIXED', 'EXECUTION_DATE']) unless validator.valid?(start_date_type) fail ArgumentError, 'invalid value for "start_date_type", must be one of #{validator.allowable_values}.' end @start_date_type = start_date_type 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 && entity_id == o.entity_id && external_id == o.external_id && name == o.name && account_id == o.account_id && order_type == o.order_type && currency == o.currency && payment_term == o.payment_term && subscription_id == o.subscription_id && subscription_target_version == o.subscription_target_version && shipping_contact_id == o.shipping_contact_id && billing_contact_id == o.billing_contact_id && predefined_discounts == o.predefined_discounts && line_items == o.line_items && line_items_net_effect == o.line_items_net_effect && start_date == o.start_date && end_date == o.end_date && term_length == o.term_length && billing_cycle == o.billing_cycle && billing_term == o.billing_term && billing_anchor_date == o.billing_anchor_date && total_amount == o.total_amount && total_list_amount == o.total_list_amount && total_list_amount_before_override == o.total_list_amount_before_override && tax_estimate == o.tax_estimate && status == o.status && executed_on == o.executed_on && updated_on == o.updated_on && executed_on_formatted == o.executed_on_formatted && ramp_interval == o.ramp_interval && order_form_template_ids == o.order_form_template_ids && order_terms == o.order_terms && sfdc_opportunity_id == o.sfdc_opportunity_id && is_primary_order_for_sfdc_opportunity == o.is_primary_order_for_sfdc_opportunity && sfdc_opportunity_name == o.sfdc_opportunity_name && sfdc_opportunity_type == o.sfdc_opportunity_type && sfdc_opportunity_stage == o.sfdc_opportunity_stage && sfdc_order_can_be_executed == o.sfdc_order_can_be_executed && opportunity_crm_type == o.opportunity_crm_type && renewal_for_subscription_id == o.renewal_for_subscription_id && renewal_for_subscription_version == o.renewal_for_subscription_version && owner_id == o.owner_id && document_master_template_id == o.document_master_template_id && purchase_order_number == o.purchase_order_number && purchase_order_required_for_invoicing == o.purchase_order_required_for_invoicing && auto_renew == o.auto_renew && approval_segment_id == o.approval_segment_id && attachment_id == o.attachment_id && composite_order_id == o.composite_order_id && expires_on == o.expires_on && custom_fields == o.custom_fields && start_date_type == o.start_date_type end # @see the `==` method # @param [Object] Object to be compared def eql?(o) self == o end # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash [id, entity_id, external_id, name, account_id, order_type, currency, payment_term, subscription_id, subscription_target_version, shipping_contact_id, billing_contact_id, predefined_discounts, line_items, line_items_net_effect, start_date, end_date, term_length, billing_cycle, billing_term, billing_anchor_date, total_amount, total_list_amount, total_list_amount_before_override, tax_estimate, status, executed_on, updated_on, executed_on_formatted, ramp_interval, order_form_template_ids, order_terms, sfdc_opportunity_id, is_primary_order_for_sfdc_opportunity, sfdc_opportunity_name, sfdc_opportunity_type, sfdc_opportunity_stage, sfdc_order_can_be_executed, opportunity_crm_type, renewal_for_subscription_id, renewal_for_subscription_version, owner_id, document_master_template_id, purchase_order_number, purchase_order_required_for_invoicing, auto_renew, approval_segment_id, attachment_id, composite_order_id, expires_on, custom_fields, start_date_type].hash end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if 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[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end # Deserializes the data based on type # @param string type Data type # @param string value Value to be deserialized # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime DateTime.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 temp_model = SubskribeDevClient.const_get(type).new temp_model.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) next if value.nil? 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