Class: RubyEcommClient::ServiceManager

Inherits:
ServiceBase show all
Defined in:
lib/ruby-ecomm-client/service_manager.rb

Constant Summary collapse

ENDPOINTS_MANAGER =
{
  :development => 'http://bonsai.dev.glbt1.gdg/Bonsai/BonsaiManager/Service.asmx',
  :production  => 'http://bonsai.prod.phx3.gdg/Bonsai/BonsaiManager/Service.asmx',
  :qa          => 'http://bonsai.test.glbt1.gdg/Bonsai/BonsaiManager/Service.asmx',
  :test        => 'http://bonsai.dev.glbt1.gdg/Bonsai/BonsaiManager/Service.asmx'
}
WSDL_MANAGER =
'manager.wsdl'

Constants inherited from ServiceBase

RubyEcommClient::ServiceBase::ID_TYPE

Instance Method Summary collapse

Methods inherited from ServiceBase

#initialize

Methods included from Utils

included

Constructor Details

This class inherits a constructor from RubyEcommClient::ServiceBase

Instance Method Details

#account_info(source_tree_id = 0) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/ruby-ecomm-client/service_manager.rb', line 12

def (source_tree_id = 0)
  result = client_manager.call(:get_account_xml, :message => (source_tree_id))
  response = convert_response(result.body[:get_account_xml_response])
  if response[:result_code] == 0
    response[:account_xml][:bonsai][:bonsai]
  else
    raise RubyEcommError.new(response[:result_code])
  end
end

#find_transition(transitions, target_pfid) ⇒ Object

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
34
35
# File 'lib/ruby-ecomm-client/service_manager.rb', line 27

def find_transition(transitions, target_pfid)
  raise ArgumentError.new('transitions must be specified') if blank?(transitions)
  raise ArgumentError.new('target_pfid must be specified') if blank?(target_pfid)

  transitions = transitions.is_a?(Array) ? transitions : [transitions]
  transitions.find do |transition|
    transition[:product_id].to_s == target_pfid.to_s
  end
end

#request_change_via_manager(target_tree_id) ⇒ Object

Raises:

  • (ArgumentError)


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ruby-ecomm-client/service_manager.rb', line 37

def request_change_via_manager(target_tree_id)
  raise ArgumentError.new('target_tree_id must be specified') if blank?(target_tree_id)

  request_hash = generate_request_change_hash
  request_hash['AccountChangeXml'] = %W(
    <ClientChange
      TreeID='#{target_tree_id}'
      ShopperID='#{config_client.shopper_id}'/>
  ).join(' ')

  result = client_manager.call(:change_account_request, :message => request_hash)
  response = convert_response(result.body[:change_account_request_response])
  if response[:result_code] == 0
    {
      :used_express_checkout => false,
      :request_result        => response[:change_account_request_result]
    }
  else
    raise RubyEcommError.new(response[:result_code], response[:change_account_request_result])
  end
end

#transitions(source_tree_id = 0) ⇒ Object



22
23
24
25
# File 'lib/ruby-ecomm-client/service_manager.rb', line 22

def transitions(source_tree_id = 0)
  transitions = (source_tree_id)[:tree][:transition]
  transitions.is_a?(Array) ? transitions : [transitions]
end