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.



13874
13875
13876
13877
13878
13879
13880
13881
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13874

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

#companyObject (readonly)

Returns the value of attribute company.



13872
13873
13874
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13872

def company
  @company
end

#emailObject (readonly)

Returns the value of attribute email.



13872
13873
13874
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13872

def email
  @email
end

#nameObject (readonly)

Returns the value of attribute name.



13872
13873
13874
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13872

def name
  @name
end

#phoneObject (readonly)

Returns the value of attribute phone.



13872
13873
13874
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13872

def phone
  @phone
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13887
13888
13889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13887

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

#to_hashObject



13891
13892
13893
13894
13895
13896
13897
13898
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13891

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

#to_jsonObject



13883
13884
13885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13883

def to_json
  JSON.dump(to_hash)
end