Class: Warb::Resources::Contact
- Defined in:
- lib/warb/resources/contact.rb
Instance Attribute Summary collapse
-
#addresses ⇒ Object
Returns the value of attribute addresses.
-
#birthday ⇒ Object
Returns the value of attribute birthday.
-
#emails ⇒ Object
Returns the value of attribute emails.
-
#name ⇒ Object
Returns the value of attribute name.
-
#org ⇒ Object
Returns the value of attribute org.
-
#phones ⇒ Object
Returns the value of attribute phones.
-
#urls ⇒ Object
Returns the value of attribute urls.
Instance Method Summary collapse
-
#add_address(**params) ⇒ Object
rubocop:enable Metrics/MethodLength.
- #add_email(**params) ⇒ Object
- #add_phone(**params) ⇒ Object
- #add_url(**params) ⇒ Object
- #build_name(**params) ⇒ Object
- #build_org(**params) ⇒ Object
-
#build_payload ⇒ Object
rubocop:disable Metrics/MethodLength.
-
#initialize(**params) ⇒ Contact
constructor
A new instance of Contact.
Methods inherited from Resource
#add_document_header, #add_image_header, #add_text_header, #add_video_header, #build_header, #build_template_named_parameter, #build_template_positional_parameter, #call
Methods included from Validation
#blank?, #raw_value, #resolve, #validates
Constructor Details
#initialize(**params) ⇒ Contact
Returns a new instance of Contact.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/warb/resources/contact.rb', line 15 def initialize(**params) super @org = @params[:org] @name = @params[:name] @birthday = @params[:birthday] @addresses = @params.fetch(:addresses, []) @emails = @params.fetch(:emails, []) @phones = @params.fetch(:phones, []) @urls = @params.fetch(:urls, []) end |
Instance Attribute Details
#addresses ⇒ Object
Returns the value of attribute addresses.
13 14 15 |
# File 'lib/warb/resources/contact.rb', line 13 def addresses @addresses end |
#birthday ⇒ Object
Returns the value of attribute birthday.
13 14 15 |
# File 'lib/warb/resources/contact.rb', line 13 def birthday @birthday end |
#emails ⇒ Object
Returns the value of attribute emails.
13 14 15 |
# File 'lib/warb/resources/contact.rb', line 13 def emails @emails end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/warb/resources/contact.rb', line 13 def name @name end |
#org ⇒ Object
Returns the value of attribute org.
13 14 15 |
# File 'lib/warb/resources/contact.rb', line 13 def org @org end |
#phones ⇒ Object
Returns the value of attribute phones.
13 14 15 |
# File 'lib/warb/resources/contact.rb', line 13 def phones @phones end |
#urls ⇒ Object
Returns the value of attribute urls.
13 14 15 |
# File 'lib/warb/resources/contact.rb', line 13 def urls @urls end |
Instance Method Details
#add_address(**params) ⇒ Object
rubocop:enable Metrics/MethodLength
46 47 48 49 50 51 52 |
# File 'lib/warb/resources/contact.rb', line 46 def add_address(**params, &) address = Components::Address.new(**params) @addresses << address block_given? ? address.tap(&) : address end |
#add_email(**params) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/warb/resources/contact.rb', line 54 def add_email(**params, &) email = Components::Email.new(**params) @emails << email block_given? ? email.tap(&) : email end |
#add_phone(**params) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/warb/resources/contact.rb', line 62 def add_phone(**params, &) phone = Components::Phone.new(**params) @phones << phone block_given? ? phone.tap(&) : phone end |
#add_url(**params) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/warb/resources/contact.rb', line 70 def add_url(**params, &) url = Components::URL.new(**params) @urls << url block_given? ? url.tap(&) : url end |
#build_name(**params) ⇒ Object
78 79 80 81 82 |
# File 'lib/warb/resources/contact.rb', line 78 def build_name(**params, &) @name = Warb::Components::Name.new(**params) block_given? ? @name.tap(&) : @name end |
#build_org(**params) ⇒ Object
84 85 86 87 88 |
# File 'lib/warb/resources/contact.rb', line 84 def build_org(**params, &) @org = Warb::Components::Org.new(**params) block_given? ? @org.tap(&) : @org end |
#build_payload ⇒ Object
rubocop:disable Metrics/MethodLength
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/warb/resources/contact.rb', line 28 def build_payload { type: 'contacts', contacts: [ { birthday: birthday, org: org.to_h, name: name.to_h, urls: urls.map(&:to_h), emails: emails.map(&:to_h), phones: phones.map(&:to_h), addresses: addresses.map(&:to_h) } ] } end |