Class: Zspay::Client

Inherits:
Resource show all
Defined in:
lib/zspay/resources/client.rb

Overview

The Client class is responsible for handling client-related actions within the Zspay platform. It allows for creating clients and their associated cards by extending the Zspay::Resource class.

Class Method Summary collapse

Methods inherited from Resource

delete, endpoint, get, headers, parse_body, parse_json, patch, post, put, req, req_form, req_json, success_request?

Class Method Details

.create(client) ⇒ OpenStruct

Creates a new client on the Zspay platform.

This method sends a POST request to the Zspay API to create a new client record. The client’s information should be provided in the form of a hash.

Parameters:

  • client (Hash)

    A hash containing the client’s information, such as name, email, etc.

Returns:

  • (OpenStruct)

    A structure containing the newly created client’s details if successful.



15
16
17
# File 'lib/zspay/resources/client.rb', line 15

def create(client)
  post("/clientes", client)
end

.create_card(client_id, card) ⇒ OpenStruct

Adds a new card for an existing client on the Zspay platform.

This method sends a POST request to add a new card to the specified client’s account. The card information, including number, expiry date, and CVV, should be provided in the form of a hash.

Parameters:

  • client_id (String)

    The unique identifier of the client to whom the card will be added.

  • card (Hash)

    A hash containing the card’s information, such as number, expiry date, and CVV.

Returns:

  • (OpenStruct)

    A structure containing the newly added card’s details if successful.



27
28
29
# File 'lib/zspay/resources/client.rb', line 27

def create_card(client_id, card)
  post("/clientes/#{client_id}/cartoes", card)
end