Class: Ittybit::AsyncTasksClient
- Inherits:
-
Object
- Object
- Ittybit::AsyncTasksClient
- Defined in:
- lib/ittybit/tasks/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(request: nil, request_options: nil) ⇒ Ittybit::Tasks::TasksCreateResponse
Creates a new task item.
-
#get(id:, request_options: nil) ⇒ Ittybit::Tasks::TasksGetResponse
Retrieves the task object for a task with the given ID.
- #initialize(request_client:) ⇒ Ittybit::AsyncTasksClient constructor
-
#list(page: nil, limit: nil, request_options: nil) ⇒ Array<Ittybit::Tasks::TasksListResponseItem>
Retrieves a paginated list of all tasks for the current project.
Constructor Details
#initialize(request_client:) ⇒ Ittybit::AsyncTasksClient
132 133 134 |
# File 'lib/ittybit/tasks/client.rb', line 132 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Ittybit::AsyncRequestClient (readonly)
128 129 130 |
# File 'lib/ittybit/tasks/client.rb', line 128 def request_client @request_client end |
Instance Method Details
#create(request: nil, request_options: nil) ⇒ Ittybit::Tasks::TasksCreateResponse
Creates a new task item. See [Tasks](/docs/tasks) for detailed coverage of all
available props and values.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/ittybit/tasks/client.rb', line 188 def create(request: nil, request_options: nil) Async do response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .api_key unless &.api_key.nil? req.headers["ACCEPT_VERSION"] = .version unless &.version.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}), "Accept-Version": "2025-08-20" }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(request_options: )}/tasks" end Ittybit::Tasks::TasksCreateResponse.from_json(json_object: response.body) end end |
#get(id:, request_options: nil) ⇒ Ittybit::Tasks::TasksGetResponse
Retrieves the task object for a task with the given ID.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/ittybit/tasks/client.rb', line 222 def get(id:, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .api_key unless &.api_key.nil? req.headers["ACCEPT_VERSION"] = .version unless &.version.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}), "Accept-Version": "2025-08-20" }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/tasks/#{id}" end Ittybit::Tasks::TasksGetResponse.from_json(json_object: response.body) end end |
#list(page: nil, limit: nil, request_options: nil) ⇒ Array<Ittybit::Tasks::TasksListResponseItem>
Retrieves a paginated list of all tasks for the current project.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/ittybit/tasks/client.rb', line 149 def list(page: nil, limit: nil, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .api_key unless &.api_key.nil? req.headers["ACCEPT_VERSION"] = .version unless &.version.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}), "Accept-Version": "2025-08-20" }.compact req.params = { **(&.additional_query_parameters || {}), "page": page, "limit": limit }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/tasks" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json Ittybit::Tasks::TasksListResponseItem.from_json(json_object: item) end end end |