Class: Centaman::Service::CreateMember
- Inherits:
-
Centaman::Service
- Object
- Wrapper
- Centaman::Service
- Centaman::Service::CreateMember
- Includes:
- JsonWrapper
- Defined in:
- lib/centaman/service/create_member.rb
Constant Summary
Constants inherited from Wrapper
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#date_of_birth ⇒ Object
readonly
Returns the value of attribute date_of_birth.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#gender ⇒ Object
readonly
Returns the value of attribute gender.
-
#is_primary ⇒ Object
readonly
Returns the value of attribute is_primary.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#phone ⇒ Object
readonly
Returns the value of attribute phone.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Attributes inherited from Wrapper
#api_password, #api_token, #api_url, #api_username, #proxie_host, #proxie_password, #proxie_port, #proxie_user
Instance Method Summary collapse
- #after_init(args) ⇒ Object
- #build_object(resp) ⇒ Object
- #endpoint ⇒ Object
- #home_address ⇒ Object
- #object_class ⇒ Object
- #options_hash ⇒ Object
Methods included from JsonWrapper
#additional_hash_to_serialize_after_response, #build_objects, #final_object_class, #objects
Methods inherited from Centaman::Service
#after_post, #fetch_all, #post, #put
Methods inherited from Wrapper
#generate_token, #headers, #initialize, #options, #payload, #payload_key, #proxy_hash, #wrap_request_in_case_of_timeout
Constructor Details
This class inherits a constructor from Centaman::Wrapper
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
7 8 9 |
# File 'lib/centaman/service/create_member.rb', line 7 def address @address end |
#date_of_birth ⇒ Object (readonly)
Returns the value of attribute date_of_birth.
7 8 9 |
# File 'lib/centaman/service/create_member.rb', line 7 def date_of_birth @date_of_birth end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
7 8 9 |
# File 'lib/centaman/service/create_member.rb', line 7 def email @email end |
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name.
7 8 9 |
# File 'lib/centaman/service/create_member.rb', line 7 def first_name @first_name end |
#gender ⇒ Object (readonly)
Returns the value of attribute gender.
7 8 9 |
# File 'lib/centaman/service/create_member.rb', line 7 def gender @gender end |
#is_primary ⇒ Object (readonly)
Returns the value of attribute is_primary.
7 8 9 |
# File 'lib/centaman/service/create_member.rb', line 7 def is_primary @is_primary end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
7 8 9 |
# File 'lib/centaman/service/create_member.rb', line 7 def last_name @last_name end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
7 8 9 |
# File 'lib/centaman/service/create_member.rb', line 7 def password @password end |
#phone ⇒ Object (readonly)
Returns the value of attribute phone.
7 8 9 |
# File 'lib/centaman/service/create_member.rb', line 7 def phone @phone end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/centaman/service/create_member.rb', line 7 def title @title end |
Instance Method Details
#after_init(args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/centaman/service/create_member.rb', line 10 def after_init(args) @first_name = args[:first_name].try(:squish) @last_name = args[:last_name].try(:squish) @address = args[:address].try(:symbolize_keys) @gender = args[:gender].try(:squish) @title = args[:title].try(:squish) @date_of_birth = args[:date_of_birth] @email = args[:email].try(:squish) @phone = args[:phone] @is_primary = args[:is_primary] || false @password = args[:password] || SecureRandom.hex end |
#build_object(resp) ⇒ Object
31 32 33 34 35 |
# File 'lib/centaman/service/create_member.rb', line 31 def build_object(resp) return build_objects(resp) if resp.respond_to?(:map) return create_error(resp) unless resp.respond_to?(:merge) @build_object ||= object_class.new(resp.merge(additional_hash_to_serialize_after_response)) end |
#endpoint ⇒ Object
23 24 25 |
# File 'lib/centaman/service/create_member.rb', line 23 def endpoint '/member_services/Member' end |
#home_address ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/centaman/service/create_member.rb', line 53 def home_address return if !address { 'street1': address[:street_address].try(:squish).try(:upcase), 'street2': address[:street_address_two].try(:squish).try(:upcase), 'suburb': address[:suburb].try(:squish).try(:upcase), 'city': address[:city].try(:squish).try(:upcase), 'state': address[:state].try(:squish).try(:upcase), 'postcode': address[:zip].try(:squish).try(:upcase), 'country': address[:country].try(:squish).try(:upcase), 'homePhone': phone.try(:delete, "^0-9"), 'workPhone': address[:work_phone].try(:delete, "^0-9"), 'mobilePhone': address[:mobile_phone].try(:delete, "^0-9") } end |
#object_class ⇒ Object
27 28 29 |
# File 'lib/centaman/service/create_member.rb', line 27 def object_class Centaman::Object::Member end |
#options_hash ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/centaman/service/create_member.rb', line 37 def [ { 'FirstName' => first_name.try(:upcase), 'LastName' => last_name.try(:upcase), 'HomeAddress' => home_address, 'Gender' => gender, 'Title' => title.try(:upcase), 'DateOfBirth' => date_of_birth, 'Email' => email.try(:upcase), 'Password' => password, 'IsPrimary' => is_primary } ].to_json end |