Class: MaliPoPay::Resources::Customers

Inherits:
Object
  • Object
show all
Defined in:
lib/malipopay/resources/customers.rb

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ Customers

Returns a new instance of Customers.



6
7
8
# File 'lib/malipopay/resources/customers.rb', line 6

def initialize(http_client)
  @http = http_client
end

Instance Method Details

#create(params) ⇒ Hash

Create a new customer

Parameters:

  • params (Hash)

    Customer parameters (name, phone, email, etc.)

Returns:

  • (Hash)

    Created customer



13
14
15
# File 'lib/malipopay/resources/customers.rb', line 13

def create(params)
  @http.post("/api/v1/customer", body: params)
end

#get(id) ⇒ Hash

Get a customer by ID

Parameters:

  • id (String)

    Customer ID

Returns:

  • (Hash)

    Customer details



27
28
29
# File 'lib/malipopay/resources/customers.rb', line 27

def get(id)
  @http.get("/api/v1/customer/#{id}")
end

#get_by_number(number) ⇒ Hash

Get a customer by customer number

Parameters:

  • number (String)

    Customer number

Returns:

  • (Hash)

    Customer details



34
35
36
# File 'lib/malipopay/resources/customers.rb', line 34

def get_by_number(number)
  @http.get("/api/v1/customer/search", params: { customerNumber: number })
end

#get_by_phone(phone) ⇒ Hash

Get a customer by phone number

Parameters:

  • phone (String)

    Phone number

Returns:

  • (Hash)

    Customer details



41
42
43
# File 'lib/malipopay/resources/customers.rb', line 41

def get_by_phone(phone)
  @http.get("/api/v1/customer/search", params: { phone: phone })
end

#list(params = {}) ⇒ Hash

List all customers

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters (page, limit, etc.)

Returns:

  • (Hash)

    Paginated list of customers



20
21
22
# File 'lib/malipopay/resources/customers.rb', line 20

def list(params = {})
  @http.get("/api/v1/customer", params: params)
end

#search(params = {}) ⇒ Hash

Search customers

Parameters:

  • params (Hash) (defaults to: {})

    Search parameters

Returns:

  • (Hash)

    Search results



48
49
50
# File 'lib/malipopay/resources/customers.rb', line 48

def search(params = {})
  @http.get("/api/v1/customer/search", params: params)
end

#verify_customer(params) ⇒ Hash

Verify a customer

Parameters:

  • params (Hash)

    Verification parameters

Returns:

  • (Hash)

    Verification response



55
56
57
# File 'lib/malipopay/resources/customers.rb', line 55

def verify_customer(params)
  @http.post("/api/v1/customer/verify", body: params)
end