Class: Centaman::Service::AuthenticateMember

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



5
6
7
# File 'lib/centaman/service/authenticate_member.rb', line 5

def email
  @email
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



5
6
7
# File 'lib/centaman/service/authenticate_member.rb', line 5

def last_name
  @last_name
end

#member_numberObject (readonly)

Returns the value of attribute member_number.



5
6
7
# File 'lib/centaman/service/authenticate_member.rb', line 5

def member_number
  @member_number
end

#passwordObject (readonly)

Returns the value of attribute password.



5
6
7
# File 'lib/centaman/service/authenticate_member.rb', line 5

def password
  @password
end

Instance Method Details

#after_init(args) ⇒ Object



7
8
9
10
11
12
# File 'lib/centaman/service/authenticate_member.rb', line 7

def after_init(args)
  @member_number = args.fetch(:member_number, nil).try(:to_i)
  @last_name = args.fetch(:last_name, nil)
  @email = args.fetch(:email, nil)
  @password = args.fetch(:password, nil)
end

#build_object(resp) ⇒ Object



22
23
24
25
26
27
# File 'lib/centaman/service/authenticate_member.rb', line 22

def build_object(resp)
  return build_objects(resp) if resp.respond_to?(:map)

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

#endpointObject



14
15
16
# File 'lib/centaman/service/authenticate_member.rb', line 14

def endpoint
  '/member_services/Authentication'
end

#object_classObject



18
19
20
# File 'lib/centaman/service/authenticate_member.rb', line 18

def object_class
  Centaman::Object::Member
end

#options_hashObject



29
30
31
32
33
34
35
36
# File 'lib/centaman/service/authenticate_member.rb', line 29

def options_hash
  {
    'MemberNumber' => member_number,
    'Surname' => last_name,
    'Email' => email,
    'Password' => password
  }.to_json
end