Class: Attio::Client
- Inherits:
-
Object
- Object
- Attio::Client
- Defined in:
- lib/attio/client.rb
Overview
Direct Known Subclasses
Constant Summary collapse
- API_BASE_URL =
The base URL for the Attio API v2
"https://api.attio.com/v2"- DEFAULT_TIMEOUT =
Default request timeout in seconds
30
Instance Attribute Summary collapse
-
#api_key ⇒ String
readonly
The API key used for authentication.
-
#timeout ⇒ Integer
readonly
The request timeout in seconds.
Instance Method Summary collapse
-
#attributes ⇒ Resources::Attributes
Access to the Attributes API resource.
-
#bulk ⇒ Resources::Bulk
Access to the Bulk Operations API resource.
-
#comments ⇒ Resources::Comments
Access to the Comments API resource.
-
#connection ⇒ HttpClient
private
Returns the HTTP connection instance for making API requests.
-
#deals ⇒ Resources::Deals
Access to the Deals API resource.
-
#initialize(api_key:, timeout: DEFAULT_TIMEOUT) ⇒ Client
constructor
Initialize a new Attio API client.
-
#lists ⇒ Resources::Lists
Access to the Lists API resource.
-
#meta ⇒ Resources::Meta
Access to the Meta API resource.
-
#notes ⇒ Resources::Notes
Access to the Notes API resource.
-
#objects ⇒ Resources::Objects
Access to the Objects API resource.
-
#rate_limiter(limiter = nil) ⇒ RateLimiter
Get or set the rate limiter for this client.
-
#records ⇒ Resources::Records
Access to the Records API resource.
-
#tasks ⇒ Resources::Tasks
Access to the Tasks API resource.
-
#threads ⇒ Resources::Threads
Access to the Threads API resource.
-
#users ⇒ Resources::Users
Access to the Users API resource.
-
#workspace_members ⇒ Resources::WorkspaceMembers
Access to the Workspace Members API resource.
-
#workspaces ⇒ Resources::Workspaces
Access to the Workspaces API resource.
Constructor Details
#initialize(api_key:, timeout: DEFAULT_TIMEOUT) ⇒ Client
Initialize a new Attio API client.
38 39 40 41 42 43 |
# File 'lib/attio/client.rb', line 38 def initialize(api_key:, timeout: DEFAULT_TIMEOUT) raise ArgumentError, "API key is required" if api_key.nil? || api_key.empty? @api_key = api_key @timeout = timeout end |
Instance Attribute Details
#api_key ⇒ String (readonly)
Returns The API key used for authentication.
25 26 27 |
# File 'lib/attio/client.rb', line 25 def api_key @api_key end |
#timeout ⇒ Integer (readonly)
Returns The request timeout in seconds.
28 29 30 |
# File 'lib/attio/client.rb', line 28 def timeout @timeout end |
Instance Method Details
#attributes ⇒ Resources::Attributes
Access to the Attributes API resource.
117 118 119 |
# File 'lib/attio/client.rb', line 117 def attributes @attributes ||= Resources::Attributes.new(self) end |
#bulk ⇒ Resources::Bulk
Access to the Bulk Operations API resource.
189 190 191 |
# File 'lib/attio/client.rb', line 189 def bulk @bulk ||= Resources::Bulk.new(self) end |
#comments ⇒ Resources::Comments
Access to the Comments API resource.
153 154 155 |
# File 'lib/attio/client.rb', line 153 def comments @comments ||= Resources::Comments.new(self) end |
#connection ⇒ HttpClient
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the HTTP connection instance for making API requests.
This method creates and configures the HTTP client with proper authentication headers and settings. The connection is cached for subsequent requests.
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/attio/client.rb', line 53 def connection @connection ||= HttpClient.new( base_url: API_BASE_URL, headers: { "Authorization" => "Bearer #{api_key}", "Accept" => "application/json", "Content-Type" => "application/json", "User-Agent" => "Attio Ruby Client/#{VERSION}", }, timeout: timeout, rate_limiter: rate_limiter ) end |
#deals ⇒ Resources::Deals
Access to the Deals API resource.
180 181 182 |
# File 'lib/attio/client.rb', line 180 def deals @deals ||= Resources::Deals.new(self) end |
#lists ⇒ Resources::Lists
Access to the Lists API resource.
99 100 101 |
# File 'lib/attio/client.rb', line 99 def lists @lists ||= Resources::Lists.new(self) end |
#meta ⇒ Resources::Meta
Access to the Meta API resource.
72 73 74 |
# File 'lib/attio/client.rb', line 72 def ||= Resources::Meta.new(self) end |
#notes ⇒ Resources::Notes
Access to the Notes API resource.
135 136 137 |
# File 'lib/attio/client.rb', line 135 def notes @notes ||= Resources::Notes.new(self) end |
#objects ⇒ Resources::Objects
Access to the Objects API resource.
90 91 92 |
# File 'lib/attio/client.rb', line 90 def objects @objects ||= Resources::Objects.new(self) end |
#rate_limiter(limiter = nil) ⇒ RateLimiter
Get or set the rate limiter for this client.
199 200 201 202 203 204 205 |
# File 'lib/attio/client.rb', line 199 def rate_limiter(limiter = nil) if limiter @rate_limiter = limiter else @rate_limiter ||= RateLimiter.new end end |
#records ⇒ Resources::Records
Access to the Records API resource.
81 82 83 |
# File 'lib/attio/client.rb', line 81 def records @records ||= Resources::Records.new(self) end |
#tasks ⇒ Resources::Tasks
Access to the Tasks API resource.
144 145 146 |
# File 'lib/attio/client.rb', line 144 def tasks @tasks ||= Resources::Tasks.new(self) end |
#threads ⇒ Resources::Threads
Access to the Threads API resource.
162 163 164 |
# File 'lib/attio/client.rb', line 162 def threads @threads ||= Resources::Threads.new(self) end |
#users ⇒ Resources::Users
Access to the Users API resource.
126 127 128 |
# File 'lib/attio/client.rb', line 126 def users @users ||= Resources::Users.new(self) end |
#workspace_members ⇒ Resources::WorkspaceMembers
Access to the Workspace Members API resource.
171 172 173 |
# File 'lib/attio/client.rb', line 171 def workspace_members @workspace_members ||= Resources::WorkspaceMembers.new(self) end |
#workspaces ⇒ Resources::Workspaces
Access to the Workspaces API resource.
108 109 110 |
# File 'lib/attio/client.rb', line 108 def workspaces @workspaces ||= Resources::Workspaces.new(self) end |