Class: WebPay::Customer

Inherits:
ApiResource show all
Defined in:
lib/webpay/customer.rb

Instance Method Summary collapse

Methods inherited from ApiResource

#initialize

Constructor Details

This class inherits a constructor from WebPay::ApiResource

Instance Method Details

#all(params = {}) ⇒ CustomerResponseList

List customers filtered by params.

Parameters:

Returns:



47
48
49
50
51
# File 'lib/webpay/customer.rb', line 47

def all(params = {})
  req = WebPay::BasicListRequest.create(params)
  raw_response = @client._request(:get, 'customers', req)
  WebPay::CustomerResponseList.new(raw_response)
end

#create(params = {}) ⇒ CustomerResponse

Create a customer object with given parameters.

Parameters:

Returns:



6
7
8
9
10
# File 'lib/webpay/customer.rb', line 6

def create(params = {})
  req = WebPay::CustomerRequestCreate.create(params)
  raw_response = @client._request(:post, 'customers', req)
  WebPay::CustomerResponse.new(raw_response)
end

#delete(params = {}) ⇒ CustomerResponse

Delete an existing customer.

Parameters:

Returns:



37
38
39
40
41
# File 'lib/webpay/customer.rb', line 37

def delete(params = {})
  req = WebPay::CustomerIdRequest.create(params)
  raw_response = @client._request(:delete, 'customers' + '/' + req.id.to_s, req)
  WebPay::CustomerResponse.new(raw_response)
end

#delete_active_card(params = {}) ⇒ CustomerResponse

Delete a card data of a customer.

Parameters:

Returns:



57
58
59
60
61
# File 'lib/webpay/customer.rb', line 57

def delete_active_card(params = {})
  req = WebPay::CustomerIdRequest.create(params)
  raw_response = @client._request(:delete, 'customers' + '/' + req.id.to_s + '/' + 'active_card', req)
  WebPay::CustomerResponse.new(raw_response)
end

#retrieve(params = {}) ⇒ CustomerResponse

Retrieve a customer object by customer id. If the customer is already deleted, “deleted” attribute becomes true.

Parameters:

Returns:



17
18
19
20
21
# File 'lib/webpay/customer.rb', line 17

def retrieve(params = {})
  req = WebPay::CustomerIdRequest.create(params)
  raw_response = @client._request(:get, 'customers' + '/' + req.id.to_s, req)
  WebPay::CustomerResponse.new(raw_response)
end

#update(params = {}) ⇒ CustomerResponse

Update an existing customer with specified parameters.

Parameters:

Returns:



27
28
29
30
31
# File 'lib/webpay/customer.rb', line 27

def update(params = {})
  req = WebPay::CustomerRequestUpdate.create(params)
  raw_response = @client._request(:post, 'customers' + '/' + req.id.to_s, req)
  WebPay::CustomerResponse.new(raw_response)
end