Class: Centaman::Service::CreatePrimaryMember

Inherits:
Centaman::Service show all
Includes:
JsonWrapper
Defined in:
lib/centaman/service/create_primary_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

#emailObject (readonly)

Returns the value of attribute email.



7
8
9
# File 'lib/centaman/service/create_primary_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/create_primary_member.rb', line 7

def first_name
  @first_name
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



7
8
9
# File 'lib/centaman/service/create_primary_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/create_primary_member.rb', line 7

def password
  @password
end

Instance Method Details

#after_init(args) ⇒ Object



9
10
11
12
13
14
# File 'lib/centaman/service/create_primary_member.rb', line 9

def after_init(args)
  @first_name = args[:first_name].try(:squish)
  @last_name = args[:last_name].try(:squish)
  @email = args[:email].try(:squish)
  @password = args[:password] || SecureRandom.hex
end

#build_object(resp) ⇒ Object



24
25
26
27
28
# File 'lib/centaman/service/create_primary_member.rb', line 24

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

#endpointObject



16
17
18
# File 'lib/centaman/service/create_primary_member.rb', line 16

def endpoint
  '/member_services/Member'
end

#object_classObject



20
21
22
# File 'lib/centaman/service/create_primary_member.rb', line 20

def object_class
  Centaman::Object::Member
end

#options_hashObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/centaman/service/create_primary_member.rb', line 30

def options_hash
  [
    {
      'FirstName' => first_name.try(:upcase),
      'LastName' => last_name.try(:upcase),
      'Email' => email.try(:upcase),
      'Password' => password,
      'IsPrimary' => true
    }
  ].to_json
end