Class: FactPulse::Client
- Inherits:
-
Object
- Object
- FactPulse::Client
- Defined in:
- lib/factpulse/helpers/client.rb
Constant Summary collapse
- DEFAULT_API_URL =
'https://factpulse.fr'
Instance Method Summary collapse
-
#get(path, **params) ⇒ Object
GET request to /api/v1/path.
-
#initialize(email, password, client_uid, api_url: DEFAULT_API_URL, timeout: 60, polling_timeout: 120) ⇒ Client
constructor
A new instance of Client.
-
#post(path, **data) ⇒ Object
POST request to /api/v1/path (JSON body).
-
#post_multipart(path, data: {}, files: {}) ⇒ Object
POST request with multipart/form-data (for file uploads).
Constructor Details
#initialize(email, password, client_uid, api_url: DEFAULT_API_URL, timeout: 60, polling_timeout: 120) ⇒ Client
Returns a new instance of Client.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/factpulse/helpers/client.rb', line 34 def initialize(email, password, client_uid, api_url: DEFAULT_API_URL, timeout: 60, polling_timeout: 120) @email = email @password = password @client_uid = client_uid @api_url = api_url.chomp('/') @timeout = timeout @polling_timeout = polling_timeout @token = nil @token_expires_at = 0 @token_mutex = Mutex.new end |
Instance Method Details
#get(path, **params) ⇒ Object
GET request to /api/v1/path
57 58 59 |
# File 'lib/factpulse/helpers/client.rb', line 57 def get(path, **params) request('GET', path, params, retry_auth: true) end |
#post(path, **data) ⇒ Object
POST request to /api/v1/path (JSON body)
47 48 49 |
# File 'lib/factpulse/helpers/client.rb', line 47 def post(path, **data) request('POST', path, data, retry_auth: true) end |
#post_multipart(path, data: {}, files: {}) ⇒ Object
POST request with multipart/form-data (for file uploads)
52 53 54 |
# File 'lib/factpulse/helpers/client.rb', line 52 def post_multipart(path, data: {}, files: {}) request_multipart(path, data, files, retry_auth: true) end |