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.



14984
14985
14986
14987
14988
14989
14990
14991
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14984

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.



14982
14983
14984
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14982

def company
  @company
end

#emailObject (readonly)

Returns the value of attribute email.



14982
14983
14984
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14982

def email
  @email
end

#nameObject (readonly)

Returns the value of attribute name.



14982
14983
14984
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14982

def name
  @name
end

#phoneObject (readonly)

Returns the value of attribute phone.



14982
14983
14984
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14982

def phone
  @phone
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14997
14998
14999
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14997

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

#to_hashObject



15001
15002
15003
15004
15005
15006
15007
15008
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15001

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

#to_jsonObject



14993
14994
14995
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14993

def to_json
  JSON.dump(to_hash)
end