require 'date' module PureCloud class Quote # The globally unique identifier for the object. attr_accessor :id attr_accessor :name attr_accessor :purchase_order attr_accessor :type attr_accessor :status attr_accessor :is_submitted attr_accessor :is_pending attr_accessor :is_frozen attr_accessor :currency # Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss.SSSZ attr_accessor :created_date # Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss.SSSZ attr_accessor :last_updated_date attr_accessor :billing_contact_email attr_accessor :billing_contact_first_name attr_accessor :billing_contact_last_name attr_accessor :billing_contact_phone attr_accessor :include_voice_charges attr_accessor :charges attr_accessor :edge_control_model attr_accessor :referral_codes attr_accessor :discount_codes attr_accessor :sales_partner_code attr_accessor :is_annual_prepay # The URI for this object attr_accessor :self_uri # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'id' => :'id', :'name' => :'name', :'purchase_order' => :'purchaseOrder', :'type' => :'type', :'status' => :'status', :'is_submitted' => :'isSubmitted', :'is_pending' => :'isPending', :'is_frozen' => :'isFrozen', :'currency' => :'currency', :'created_date' => :'createdDate', :'last_updated_date' => :'lastUpdatedDate', :'billing_contact_email' => :'billingContactEmail', :'billing_contact_first_name' => :'billingContactFirstName', :'billing_contact_last_name' => :'billingContactLastName', :'billing_contact_phone' => :'billingContactPhone', :'include_voice_charges' => :'includeVoiceCharges', :'charges' => :'charges', :'edge_control_model' => :'edgeControlModel', :'referral_codes' => :'referralCodes', :'discount_codes' => :'discountCodes', :'sales_partner_code' => :'salesPartnerCode', :'is_annual_prepay' => :'isAnnualPrepay', :'self_uri' => :'selfUri' } end # Attribute type mapping. def self.swagger_types { :'id' => :'String', :'name' => :'String', :'purchase_order' => :'String', :'type' => :'String', :'status' => :'String', :'is_submitted' => :'BOOLEAN', :'is_pending' => :'BOOLEAN', :'is_frozen' => :'BOOLEAN', :'currency' => :'String', :'created_date' => :'DateTime', :'last_updated_date' => :'DateTime', :'billing_contact_email' => :'String', :'billing_contact_first_name' => :'String', :'billing_contact_last_name' => :'String', :'billing_contact_phone' => :'String', :'include_voice_charges' => :'BOOLEAN', :'charges' => :'Array', :'edge_control_model' => :'String', :'referral_codes' => :'Array', :'discount_codes' => :'Array', :'sales_partner_code' => :'String', :'is_annual_prepay' => :'BOOLEAN', :'self_uri' => :'String' } end def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} if attributes[:'id'] self.id = attributes[:'id'] end if attributes[:'name'] self.name = attributes[:'name'] end if attributes[:'purchaseOrder'] self.purchase_order = attributes[:'purchaseOrder'] end if attributes[:'type'] self.type = attributes[:'type'] end if attributes[:'status'] self.status = attributes[:'status'] end if attributes[:'isSubmitted'] self.is_submitted = attributes[:'isSubmitted'] else self.is_submitted = false end if attributes[:'isPending'] self.is_pending = attributes[:'isPending'] else self.is_pending = false end if attributes[:'isFrozen'] self.is_frozen = attributes[:'isFrozen'] else self.is_frozen = false end if attributes[:'currency'] self.currency = attributes[:'currency'] end if attributes[:'createdDate'] self.created_date = attributes[:'createdDate'] end if attributes[:'lastUpdatedDate'] self.last_updated_date = attributes[:'lastUpdatedDate'] end if attributes[:'billingContactEmail'] self.billing_contact_email = attributes[:'billingContactEmail'] end if attributes[:'billingContactFirstName'] self.billing_contact_first_name = attributes[:'billingContactFirstName'] end if attributes[:'billingContactLastName'] self.billing_contact_last_name = attributes[:'billingContactLastName'] end if attributes[:'billingContactPhone'] self.billing_contact_phone = attributes[:'billingContactPhone'] end if attributes[:'includeVoiceCharges'] self.include_voice_charges = attributes[:'includeVoiceCharges'] else self.include_voice_charges = false end if attributes[:'charges'] if (value = attributes[:'charges']).is_a?(Array) self.charges = value end end if attributes[:'edgeControlModel'] self.edge_control_model = attributes[:'edgeControlModel'] end if attributes[:'referralCodes'] if (value = attributes[:'referralCodes']).is_a?(Array) self.referral_codes = value end end if attributes[:'discountCodes'] if (value = attributes[:'discountCodes']).is_a?(Array) self.discount_codes = value end end if attributes[:'salesPartnerCode'] self.sales_partner_code = attributes[:'salesPartnerCode'] end if attributes[:'isAnnualPrepay'] self.is_annual_prepay = attributes[:'isAnnualPrepay'] else self.is_annual_prepay = false end if attributes[:'selfUri'] self.self_uri = attributes[:'selfUri'] end end # Custom attribute writer method checking allowed values (enum). def type=(type) allowed_values = ["NEW_SUBSCRIPTION", "AMENDMENT"] if type && !allowed_values.include?(type) fail "invalid value for 'type', must be one of #{allowed_values}" end @type = type end # Custom attribute writer method checking allowed values (enum). def status=(status) allowed_values = ["IN_PROGRESS", "SUBMITTED", "FROZEN"] if status && !allowed_values.include?(status) fail "invalid value for 'status', must be one of #{allowed_values}" end @status = status end # Check equality by comparing each attribute. def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && name == o.name && purchase_order == o.purchase_order && type == o.type && status == o.status && is_submitted == o.is_submitted && is_pending == o.is_pending && is_frozen == o.is_frozen && currency == o.currency && created_date == o.created_date && last_updated_date == o.last_updated_date && billing_contact_email == o.billing_contact_email && billing_contact_first_name == o.billing_contact_first_name && billing_contact_last_name == o.billing_contact_last_name && billing_contact_phone == o.billing_contact_phone && include_voice_charges == o.include_voice_charges && charges == o.charges && edge_control_model == o.edge_control_model && referral_codes == o.referral_codes && discount_codes == o.discount_codes && sales_partner_code == o.sales_partner_code && is_annual_prepay == o.is_annual_prepay && self_uri == o.self_uri end # @see the `==` method def eql?(o) self == o end # Calculate hash code according to all attributes. def hash [id, name, purchase_order, type, status, is_submitted, is_pending, is_frozen, currency, created_date, last_updated_date, billing_contact_email, billing_contact_first_name, billing_contact_last_name, billing_contact_phone, include_voice_charges, charges, edge_control_model, referral_codes, discount_codes, sales_partner_code, is_annual_prepay, self_uri].hash end # build the object from hash def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) else #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) else # data not found in attributes(hash), not an issue as the data can be optional end end self end 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 =~ /^(true|t|yes|y|1)$/i true else false end 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 _model = Object.const_get("PureCloud").const_get(type).new _model.build_from_hash(value) end end def to_s to_hash.to_s end # to_body is an alias to to_body (backward compatibility)) def to_body to_hash end # return 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 # Method to output non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value 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