Skip to content

Commit

Permalink
add getItem api
Browse files Browse the repository at this point in the history
  • Loading branch information
mya-zaki committed Nov 1, 2023
1 parent 1affe71 commit 8265dbc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/autodesk/forge/data_management/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ def versions

JSON.parse(response.body)
end

def get
response = get_request("/data/v1/projects/#{@project_id}/items/#{URI.encode_www_form_component(@item_id)}")

JSON.parse(response.body)
end
end
end
end
Expand Down
19 changes: 19 additions & 0 deletions spec/autodesk/forge/data_management/item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,23 @@
expect(versions['data']).to be_eql('dummy-data')
end
end

describe '#item' do
let(:project_id) { 'dummy-project-id'}
let(:item_id) { 'dummy-item-id'}

it 'sends a request to the endpoint' do
stub_hubs = stub_request(:get, "https://developer.api.autodesk.com/data/v1/projects/#{project_id}/items/#{URI.encode_www_form_component(item_id)}")
.with(headers: { Authorization: 'Bearer dummy-access-token'})
.to_return({ body: { data: 'dummy-data' }.to_json })

credentials = { 'access_token' => 'dummy-access-token' }

itemApi = Autodesk::Forge::DataManagement::Item.new(project_id: project_id, item_id: item_id, credentials: credentials)
item = itemApi.get

expect(stub_hubs).to have_been_requested
expect(item['data']).to be_eql('dummy-data')
end
end
end

0 comments on commit 8265dbc

Please sign in to comment.