Class: Centaman::Service::UpdateMember

Inherits:
Centaman::Service show all
Includes:
JsonWrapper
Defined in:
lib/centaman/service/update_member.rb

Constant Summary

Constants inherited from Wrapper

Wrapper::DEFAULT_TIMEOUT_TIME

Instance Attribute Summary collapse

Attributes inherited from Wrapper

#api_password, #api_token, #api_url, #api_username, #proxie_host, #proxie_password, #proxie_port, #proxie_user

Instance Method Summary collapse

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

#addressObject (readonly)

Returns the value of attribute address.



7
8
9
# File 'lib/centaman/service/update_member.rb', line 7

def address
  @address
end

#date_of_birthObject (readonly)

Returns the value of attribute date_of_birth.



7
8
9
# File 'lib/centaman/service/update_member.rb', line 7

def date_of_birth
  @date_of_birth
end

#emailObject (readonly)

Returns the value of attribute email.



7
8
9
# File 'lib/centaman/service/update_member.rb', line 7

def email
  @email
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



7
8
9
# File 'lib/centaman/service/update_member.rb', line 7

def first_name
  @first_name
end

#genderObject (readonly)

Returns the value of attribute gender.



7
8
9
# File 'lib/centaman/service/update_member.rb', line 7

def gender
  @gender
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/centaman/service/update_member.rb', line 7

def id
  @id
end

#is_primaryObject (readonly)

Returns the value of attribute is_primary.



7
8
9
# File 'lib/centaman/service/update_member.rb', line 7

def is_primary
  @is_primary
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



7
8
9
# File 'lib/centaman/service/update_member.rb', line 7

def last_name
  @last_name
end

#passwordObject (readonly)

Returns the value of attribute password.



7
8
9
# File 'lib/centaman/service/update_member.rb', line 7

def password
  @password
end

#phoneObject (readonly)

Returns the value of attribute phone.



7
8
9
# File 'lib/centaman/service/update_member.rb', line 7

def phone
  @phone
end

Instance Method Details

#after_init(args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/centaman/service/update_member.rb', line 10

def after_init(args)
  @id = args[:id].try(:to_i)
  @first_name = args[:first_name].try(:squish)
  @last_name = args[:last_name].try(:squish)
  @address = args[:address].try(:symbolize_keys)
  @gender = args[:gender]
  @date_of_birth = args[:date_of_birth]
  @phone = args[:phone]
  @email = args[:email].try(:squish)
  @password = args[:password]
  @is_primary = args[:is_primary]
end

#build_object(resp) ⇒ Object



31
32
33
34
# File 'lib/centaman/service/update_member.rb', line 31

def build_object(resp)
  return update_error(resp) unless resp.respond_to?(:merge)
  @build_object ||= object_class.new(resp.merge(additional_hash_to_serialize_after_response))
end

#endpointObject



23
24
25
# File 'lib/centaman/service/update_member.rb', line 23

def endpoint
  "/member_services/Member/#{id}"
end

#object_classObject



27
28
29
# File 'lib/centaman/service/update_member.rb', line 27

def object_class
  Centaman::Object::Member
end

#options_hashObject



49
50
51
# File 'lib/centaman/service/update_member.rb', line 49

def options_hash
  options_hash_no_json.compact.to_json
end

#options_hash_no_jsonObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/centaman/service/update_member.rb', line 36

def options_hash_no_json
  {
    'FirstName' => first_name.try(:upcase),
    'LastName' => last_name.try(:upcase),
    'HomeAddress' => home_address,
    'Gender' => gender,
    'DateOfBirth' => date_of_birth,
    'Email' => email.try(:upcase),
    'Password' => password,
    'IsPrimary' => is_primary
  }
end