Class: AxTrack::AssetResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/ax_track/resources/asset_resource.rb

Constant Summary

Constants inherited from Resource

Resource::ApiError, Resource::ApiRequestsQuotaReachedError, Resource::BadRequestError, Resource::ForbiddenError, Resource::HTTP_BAD_REQUEST_CODE, Resource::HTTP_FORBIDDEN_CODE, Resource::HTTP_NOT_FOUND_CODE, Resource::HTTP_OK_CODE, Resource::HTTP_UNAUTHORIZED_CODE, Resource::HTTP_UNPROCESSABLE_ENTITY_CODE, Resource::NotFoundError, Resource::UnauthorizedError, Resource::UnprocessableEntityError

Instance Attribute Summary

Attributes inherited from Resource

#client, #response

Instance Method Summary collapse

Methods inherited from Resource

#error_class, #initialize, #request, #response_successful?

Constructor Details

This class inherits a constructor from AxTrack::Resource

Instance Method Details

#list(per_page: nil, cursor: nil) ⇒ Object



4
5
6
7
8
9
# File 'lib/ax_track/resources/asset_resource.rb', line 4

def list(per_page: nil, cursor: nil)
  Collection.from_response response = request(endpoint: "assets",
                                              params: {per_page: per_page, cursor: cursor}.compact),
                           key: 'results',
                           type: Asset
end

#retrieve(asset_id) ⇒ Object



11
12
13
14
# File 'lib/ax_track/resources/asset_resource.rb', line 11

def retrieve(asset_id)
  Asset.new request(http_method: :get,
                      endpoint: "assets/#{asset_id}").body
end

#update(asset_id, headers: {}, **attributes) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/ax_track/resources/asset_resource.rb', line 16

def update(asset_id, headers: {}, **attributes)
  Asset.new request(http_method: :patch,
                    endpoint:  "assets/#{asset_id}",
                    body: attributes,
                    headers: {}).body

end