Class: Fizzy::Client
- Inherits:
-
Object
- Object
- Fizzy::Client
- Defined in:
- lib/fizzy/client.rb
Overview
Main client for the Fizzy API.
Client holds shared resources and provides service accessors for all 15 Fizzy services. Unlike Basecamp’s Client -> AccountClient pattern, Fizzy does not require an account ID – all services are available directly on the Client.
Instance Attribute Summary collapse
-
#config ⇒ Config
readonly
Client configuration.
-
#hooks ⇒ Hooks
readonly
private
Returns the observability hooks.
-
#http ⇒ Http
readonly
private
Returns the HTTP client for making requests.
Services collapse
- #boards ⇒ Services::BoardsService
- #cards ⇒ Services::CardsService
- #columns ⇒ Services::ColumnsService
- #comments ⇒ Services::CommentsService
- #devices ⇒ Services::DevicesService
- #identity ⇒ Services::IdentityService
- #miscellaneous ⇒ Services::MiscellaneousService
- #notifications ⇒ Services::NotificationsService
- #pins ⇒ Services::PinsService
- #reactions ⇒ Services::ReactionsService
- #sessions ⇒ Services::SessionsService
- #steps ⇒ Services::StepsService
- #tags ⇒ Services::TagsService
- #uploads ⇒ Services::UploadsService
- #users ⇒ Services::UsersService
- #webhooks ⇒ Services::WebhooksService
Instance Method Summary collapse
-
#delete(path, retryable: nil) ⇒ Response
Performs a DELETE request.
-
#get(path, params: {}) ⇒ Response
Performs a GET request.
-
#initialize(config:, token_provider: nil, auth_strategy: nil, hooks: nil) ⇒ Client
constructor
Creates a new Fizzy API client.
-
#paginate(path, params: {}) {|Hash| ... } ⇒ Enumerator
Fetches all pages of a paginated resource.
-
#patch(path, body: nil) ⇒ Response
Performs a PATCH request.
-
#post(path, body: nil, retryable: nil) ⇒ Response
Performs a POST request.
-
#post_raw(path, body:, content_type:) ⇒ Response
Performs a POST request with raw binary data.
-
#put(path, body: nil) ⇒ Response
Performs a PUT request.
Constructor Details
#initialize(config:, token_provider: nil, auth_strategy: nil, hooks: nil) ⇒ Client
Creates a new Fizzy API client.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fizzy/client.rb', line 39 def initialize(config:, token_provider: nil, auth_strategy: nil, hooks: nil) raise ArgumentError, "provide either token_provider or auth_strategy, not both" if token_provider && auth_strategy raise ArgumentError, "provide token_provider or auth_strategy" if !token_provider && !auth_strategy @config = config @hooks = hooks || NoopHooks.new @http = Http.new(config: config, token_provider: token_provider, auth_strategy: auth_strategy, hooks: @hooks) @services = {} @mutex = Mutex.new end |
Instance Attribute Details
#config ⇒ Config (readonly)
Returns client configuration.
31 32 33 |
# File 'lib/fizzy/client.rb', line 31 def config @config end |
#hooks ⇒ Hooks (readonly)
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 observability hooks.
58 59 60 |
# File 'lib/fizzy/client.rb', line 58 def hooks @hooks end |
#http ⇒ Http (readonly)
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 client for making requests.
53 54 55 |
# File 'lib/fizzy/client.rb', line 53 def http @http end |
Instance Method Details
#boards ⇒ Services::BoardsService
128 129 130 |
# File 'lib/fizzy/client.rb', line 128 def boards service(:boards) { Services::BoardsService.new(self) } end |
#cards ⇒ Services::CardsService
138 139 140 |
# File 'lib/fizzy/client.rb', line 138 def cards service(:cards) { Services::CardsService.new(self) } end |
#columns ⇒ Services::ColumnsService
133 134 135 |
# File 'lib/fizzy/client.rb', line 133 def columns service(:columns) { Services::ColumnsService.new(self) } end |
#comments ⇒ Services::CommentsService
143 144 145 |
# File 'lib/fizzy/client.rb', line 143 def comments service(:comments) { Services::CommentsService.new(self) } end |
#delete(path, retryable: nil) ⇒ Response
Performs a DELETE request.
97 98 99 |
# File 'lib/fizzy/client.rb', line 97 def delete(path, retryable: nil) @http.delete(path, retryable: retryable) end |
#devices ⇒ Services::DevicesService
193 194 195 |
# File 'lib/fizzy/client.rb', line 193 def devices service(:devices) { Services::DevicesService.new(self) } end |
#get(path, params: {}) ⇒ Response
Performs a GET request.
64 65 66 |
# File 'lib/fizzy/client.rb', line 64 def get(path, params: {}) @http.get(path, params: params) end |
#identity ⇒ Services::IdentityService
123 124 125 |
# File 'lib/fizzy/client.rb', line 123 def identity service(:identity) { Services::IdentityService.new(self) } end |
#miscellaneous ⇒ Services::MiscellaneousService
198 199 200 |
# File 'lib/fizzy/client.rb', line 198 def miscellaneous service(:miscellaneous) { Services::MiscellaneousService.new(self) } end |
#notifications ⇒ Services::NotificationsService
158 159 160 |
# File 'lib/fizzy/client.rb', line 158 def notifications service(:notifications) { Services::NotificationsService.new(self) } end |
#paginate(path, params: {}) {|Hash| ... } ⇒ Enumerator
Fetches all pages of a paginated resource.
116 117 118 |
# File 'lib/fizzy/client.rb', line 116 def paginate(path, params: {}, &) @http.paginate(path, params: params, &) end |
#patch(path, body: nil) ⇒ Response
Performs a PATCH request.
89 90 91 |
# File 'lib/fizzy/client.rb', line 89 def patch(path, body: nil) @http.patch(path, body: body) end |
#pins ⇒ Services::PinsService
173 174 175 |
# File 'lib/fizzy/client.rb', line 173 def pins service(:pins) { Services::PinsService.new(self) } end |
#post(path, body: nil, retryable: nil) ⇒ Response
Performs a POST request.
73 74 75 |
# File 'lib/fizzy/client.rb', line 73 def post(path, body: nil, retryable: nil) @http.post(path, body: body, retryable: retryable) end |
#post_raw(path, body:, content_type:) ⇒ Response
Performs a POST request with raw binary data. Used for file uploads.
107 108 109 |
# File 'lib/fizzy/client.rb', line 107 def post_raw(path, body:, content_type:) @http.post_raw(path, body: body, content_type: content_type) end |
#put(path, body: nil) ⇒ Response
Performs a PUT request.
81 82 83 |
# File 'lib/fizzy/client.rb', line 81 def put(path, body: nil) @http.put(path, body: body) end |
#reactions ⇒ Services::ReactionsService
153 154 155 |
# File 'lib/fizzy/client.rb', line 153 def reactions service(:reactions) { Services::ReactionsService.new(self) } end |
#sessions ⇒ Services::SessionsService
188 189 190 |
# File 'lib/fizzy/client.rb', line 188 def sessions service(:sessions) { Services::SessionsService.new(self) } end |
#steps ⇒ Services::StepsService
148 149 150 |
# File 'lib/fizzy/client.rb', line 148 def steps service(:steps) { Services::StepsService.new(self) } end |
#tags ⇒ Services::TagsService
163 164 165 |
# File 'lib/fizzy/client.rb', line 163 def service(:tags) { Services::TagsService.new(self) } end |
#uploads ⇒ Services::UploadsService
178 179 180 |
# File 'lib/fizzy/client.rb', line 178 def uploads service(:uploads) { Services::UploadsService.new(self) } end |
#users ⇒ Services::UsersService
168 169 170 |
# File 'lib/fizzy/client.rb', line 168 def users service(:users) { Services::UsersService.new(self) } end |
#webhooks ⇒ Services::WebhooksService
183 184 185 |
# File 'lib/fizzy/client.rb', line 183 def webhooks service(:webhooks) { Services::WebhooksService.new(self) } end |