Class: BeeiqAPI::Contact

Inherits:
Object
  • Object
show all
Defined in:
lib/beeiq_api/contact.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Contact

Returns a new instance of Contact.

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/beeiq_api/contact.rb', line 18

def initialize(options = {})
  @contact_type = options[:contact_type] || Config::ContactType::CUSTOMER
  @name = options[:name]
  @lastname = options[:lastname]
  @title = options[:title]
  @passport = options[:passport]
  @gender = options[:gender]
  @date_of_birth = options[:date_of_birth]
  @emails = options[:emails]
  @phones = options[:phones]
  @addresses = options[:addresses]
  @im = options[:im]
  @tag = options[:tag]
  @cus_fields = options[:cus_fields]
  @company_contact = options[:company_contact]

  raise ArgumentError, 'name is required' if @name.to_s.empty?
end

Instance Attribute Details

#addressesObject

Returns the value of attribute addresses.



12
13
14
# File 'lib/beeiq_api/contact.rb', line 12

def addresses
  @addresses
end

#company_contactObject

Returns the value of attribute company_contact.



16
17
18
# File 'lib/beeiq_api/contact.rb', line 16

def company_contact
  @company_contact
end

#contact_typeObject

Returns the value of attribute contact_type.



3
4
5
# File 'lib/beeiq_api/contact.rb', line 3

def contact_type
  @contact_type
end

#cus_fieldsObject

Returns the value of attribute cus_fields.



15
16
17
# File 'lib/beeiq_api/contact.rb', line 15

def cus_fields
  @cus_fields
end

#date_of_birthObject

Returns the value of attribute date_of_birth.



9
10
11
# File 'lib/beeiq_api/contact.rb', line 9

def date_of_birth
  @date_of_birth
end

#emailsObject

Returns the value of attribute emails.



10
11
12
# File 'lib/beeiq_api/contact.rb', line 10

def emails
  @emails
end

#genderObject

Returns the value of attribute gender.



8
9
10
# File 'lib/beeiq_api/contact.rb', line 8

def gender
  @gender
end

#imObject

Returns the value of attribute im.



13
14
15
# File 'lib/beeiq_api/contact.rb', line 13

def im
  @im
end

#lastnameObject

Returns the value of attribute lastname.



5
6
7
# File 'lib/beeiq_api/contact.rb', line 5

def lastname
  @lastname
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/beeiq_api/contact.rb', line 4

def name
  @name
end

#passportObject

Returns the value of attribute passport.



7
8
9
# File 'lib/beeiq_api/contact.rb', line 7

def passport
  @passport
end

#phonesObject

Returns the value of attribute phones.



11
12
13
# File 'lib/beeiq_api/contact.rb', line 11

def phones
  @phones
end

#tagObject

Returns the value of attribute tag.



14
15
16
# File 'lib/beeiq_api/contact.rb', line 14

def tag
  @tag
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/beeiq_api/contact.rb', line 6

def title
  @title
end

Instance Method Details

#payloadObject



56
57
58
# File 'lib/beeiq_api/contact.rb', line 56

def payload
  payload_raw.delete_if { |k, v| v.nil? || (!v.kind_of?(Integer) && v.empty?)  }
end

#payload_rawObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/beeiq_api/contact.rb', line 37

def payload_raw
  {
    contactType: @contact_type,
    name: @name,
    lastname: @lastname,
    title: @title,
    passport: @passport,
    gender: @gender,
    dateOfBirth: @date_of_birth,
    emails: @emails,
    phones: @phones,
    addresses: @addresses,
    im: @im,
    tag: @tag,
    cusFields: @cus_fields,
    companyContact: @company_contact
  }
end