Class: CustomerManager

Inherits:
Object
  • Object
show all
Defined in:
lib/Managers/customer_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(CroemincGatewayObject) ⇒ CustomerManager

Returns a new instance of CustomerManager.



13
14
15
# File 'lib/Managers/customer_manager.rb', line 13

def initialize(CroemincGatewayObject)
  @CroemincGatewayObject = CroemincGatewayObject
end

Instance Method Details

#GetCustomerByIdentifier(identifer) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/Managers/customer_manager.rb', line 77

def GetCustomerByIdentifier(identifer)
  custSearch = CustomerSearch.new
  custSearchOpts = CustomerSearchOption.new

  custSearch.UniqueIdentifier = identifer

  custSearchOpts.IncludeAll = false
  custSearchOpts.IncludeAssociatedEntities = true
  custSearchOpts.IncludeCardInstruments = true
  custSearchOpts.IncludePaymentInstructions = true

  custSearch.SearchOption = custSearchOpts    

  foundCustomersList = SearchCustomer(custSearch)

  customer = Customer.new
  customer = foundCustomersList[0];   
  
  return customer
end

#SaveCustomer(customerObject) ⇒ Object

Save Customer



18
19
20
21
22
# File 'lib/Managers/customer_manager.rb', line 18

def SaveCustomer(customerObject)

  return SaveCustomerInternal(customerObject)

end

#SearchCustomer(customerFilters) ⇒ Object

Search Customer Returns List of Customer objects



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/Managers/customer_manager.rb', line 33

def SearchCustomer(customerFilters) #CustomerSearch type
  reqData = CreateRequestObject(customerFilters)
  apiHelper = APIHelper.new
  responseModel = ResponseModel.new
  responseModel = apiHelper.SendAPIRequest(reqData, @CroemincGatewayObject.instance_variable_get("@gatewayURL") + "Customer/GetCustomersByFilter")

  #if response object is not nill, and
  # response.ResponseMessage (customer model) is
  # not nill, deserialize it.

  if (responseModel && responseModel.instance_variable_get("@responseMessage"))

    #puts "RESULT-INSIDE: " + responseModel.instance_variable_get("@responseMessage")

    #Search Customers returns array of customers from API
    responseMsgArr = responseModel.instance_variable_get("@responseMessage")

    #if(responseMsg.instance_of? Array)
     # puts "ITS ARRAY!"
    #else
     # puts "ITS OBJECT!"
    #end

    customersList = []

    modelParsingHelper = ModelParser.new

    objArray = JSON.parse(responseMsgArr)
    objArray.each do |obj|

      buffCustomer = modelParsingHelper.ParseCustomerObject(obj)
      if(buffCustomer)
        customersList << buffCustomer
      end

    end


    end

  return customersList

end

#UpdateCustomer(customerObject) ⇒ Object

Update Customer



25
26
27
28
29
# File 'lib/Managers/customer_manager.rb', line 25

def UpdateCustomer(customerObject)

  return SaveCustomerInternal(customerObject)

end