Class: Io::Flow::V0::Models::Contact

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Defines structured fields for a contact person. Typically used for specifying contact person for an account, shipment, or organization representative

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Contact

Returns a new instance of Contact.



11201
11202
11203
11204
11205
11206
11207
11208
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11201

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:name], 'Contact')
  @name = (x = opts.delete(:name); x.is_a?(::Io::Flow::V0::Models::Name) ? x : ::Io::Flow::V0::Models::Name.new(x))
  @company = (x = opts.delete(:company); x.nil? ? nil : HttpClient::Preconditions.assert_class('company', x, String))
  @email = (x = opts.delete(:email); x.nil? ? nil : HttpClient::Preconditions.assert_class('email', x, String))
  @phone = (x = opts.delete(:phone); x.nil? ? nil : HttpClient::Preconditions.assert_class('phone', x, String))
end

Instance Attribute Details

#company ⇒ Object (readonly)

Returns the value of attribute company.



11199
11200
11201
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11199

def company
  @company
end

#email ⇒ Object (readonly)

Returns the value of attribute email.



11199
11200
11201
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11199

def email
  @email
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



11199
11200
11201
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11199

def name
  @name
end

#phone ⇒ Object (readonly)

Returns the value of attribute phone.



11199
11200
11201
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11199

def phone
  @phone
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



11214
11215
11216
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11214

def copy(incoming={})
  Contact.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hash ⇒ Object



11218
11219
11220
11221
11222
11223
11224
11225
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11218

def to_hash
  {
    :name => name.to_hash,
    :company => company,
    :email => email,
    :phone => phone
  }
end

#to_json ⇒ Object



11210
11211
11212
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11210

def to_json
  JSON.dump(to_hash)
end