Class: Centaman::Service::CreateSecondaryMembers

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

#primary_member_idObject (readonly)

Returns the value of attribute primary_member_id.



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

def primary_member_id
  @primary_member_id
end

#secondary_membersObject (readonly)

Returns the value of attribute secondary_members.



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

def secondary_members
  @secondary_members
end

Instance Method Details

#after_init(args) ⇒ Object



9
10
11
12
# File 'lib/centaman/service/create_secondary_members.rb', line 9

def after_init(args)
  @primary_member_id = args.fetch(:primary_member_id, nil)
  @secondary_members = args.fetch(:secondary_members, [])
end

#build_object(resp) ⇒ Object



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

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



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

def endpoint
  '/member_services/Member'
end

#object_classObject



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

def object_class
  Centaman::Object::Member
end

#options_hashObject



29
30
31
32
# File 'lib/centaman/service/create_secondary_members.rb', line 29

def options_hash
  request_body = secondary_members.map { |m| build_member(m) }
  request_body.to_json
end