Class: Namabar::Client
- Inherits:
-
Object
- Object
- Namabar::Client
- Includes:
- HTTParty, Endpoints
- Defined in:
- lib/namabar/client.rb
Overview
HTTP client for interacting with the Namabar API
This class provides the core HTTP functionality for making requests to the Namabar API. It uses HTTParty for HTTP operations and includes all endpoint methods from the Endpoints module.
The client automatically handles:
-
Base URI configuration
-
Authentication via API key headers
-
Content-Type and Accept headers
-
JSON request/response handling
Instance Method Summary collapse
-
#default_options ⇒ Hash
Get default HTTP options for requests.
-
#initialize ⇒ Client
constructor
Initialize a new Namabar API client.
Methods included from Endpoints
#create_verification_code, #get_message, #get_message_status, #get_verification_code_by_id, #send_message, #verify_verification_code
Constructor Details
#initialize ⇒ Client
Initialize a new Namabar API client
Creates a new client instance using the global Namabar configuration. The client will be configured with the API key and default headers required for authentication and proper JSON communication.
56 57 58 59 60 61 62 63 |
# File 'lib/namabar/client.rb', line 56 def initialize @config = .configuration self.class.headers( 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-API-Key' => @config.api_key ) end |
Instance Method Details
#default_options ⇒ Hash
Get default HTTP options for requests
Returns a hash containing the default options that should be included with every HTTP request, including headers for authentication and content type.
76 77 78 |
# File 'lib/namabar/client.rb', line 76 def { headers: self.class.headers } end |