From 34e8e31a387fdfed28efbdfb6a2183a5c27a43a0 Mon Sep 17 00:00:00 2001 From: mya-zaki Date: Mon, 8 May 2023 15:23:52 +0900 Subject: [PATCH] Revert "Add ModelProperties API" This reverts commit be623d4e7ccd51a7575d56b0864b541bc9ba8aa3. --- lib/autodesk/forge.rb | 1 - lib/autodesk/forge/acc_model_properties.rb | 9 --- .../forge/acc_model_properties/index.rb | 33 --------- .../forge/acc_model_properties/query.rb | 35 ---------- lib/autodesk/forge/api.rb | 9 --- .../forge/acc_model_properties/index_spec.rb | 42 ------------ .../forge/acc_model_properties/query_spec.rb | 68 ------------------- 7 files changed, 197 deletions(-) delete mode 100644 lib/autodesk/forge/acc_model_properties.rb delete mode 100644 lib/autodesk/forge/acc_model_properties/index.rb delete mode 100644 lib/autodesk/forge/acc_model_properties/query.rb delete mode 100644 spec/autodesk/forge/acc_model_properties/index_spec.rb delete mode 100644 spec/autodesk/forge/acc_model_properties/query_spec.rb diff --git a/lib/autodesk/forge.rb b/lib/autodesk/forge.rb index d254223..99f7950 100644 --- a/lib/autodesk/forge.rb +++ b/lib/autodesk/forge.rb @@ -4,7 +4,6 @@ require_relative 'forge/data_management' require_relative 'forge/model_derivative' -require_relative 'forge/acc_model_properties' require 'net/http' require 'json' diff --git a/lib/autodesk/forge/acc_model_properties.rb b/lib/autodesk/forge/acc_model_properties.rb deleted file mode 100644 index d879501..0000000 --- a/lib/autodesk/forge/acc_model_properties.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Autodesk - class Forge - module AccModelProperties - end - end -end - -require_relative 'acc_model_properties/index' -require_relative 'acc_model_properties/query' \ No newline at end of file diff --git a/lib/autodesk/forge/acc_model_properties/index.rb b/lib/autodesk/forge/acc_model_properties/index.rb deleted file mode 100644 index 379c7a3..0000000 --- a/lib/autodesk/forge/acc_model_properties/index.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'autodesk/forge/api' - -module Autodesk - class Forge - module AccModelProperties - class Index < Forge::API - def initialize(project_id:, index_id: nil, credentials:) - @project_id = project_id - @index_id = index_id - @credentials = credentials - end - - def create(urn) - body = { - versions: [ - { versionUrn: urn } - ] - } - response = post_request("/construction/index/v2/projects/#{@project_id}/indexes:batch-status", body) - - JSON.parse(response.body) - end - - def get - response = get_request("/construction/index/v2/projects/#{@project_id}/indexes/#{@index_id}") - - JSON.parse(response.body) - end - - end - end - end -end \ No newline at end of file diff --git a/lib/autodesk/forge/acc_model_properties/query.rb b/lib/autodesk/forge/acc_model_properties/query.rb deleted file mode 100644 index 30572ca..0000000 --- a/lib/autodesk/forge/acc_model_properties/query.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'autodesk/forge/api' - -module Autodesk - class Forge - module AccModelProperties - class Query < Forge::API - def initialize(project_id:, index_id:, query_id: nil, credentials:) - @project_id = project_id - @index_id = index_id - @query_id = query_id - @credentials = credentials - end - - def create(parameter) - response = post_request("/construction/index/v2/projects/#{@project_id}/indexes/#{@index_id}/queries", parameter) - - JSON.parse(response.body) - end - - def get - response = get_request("/construction/index/v2/projects/#{@project_id}/indexes/#{@index_id}/queries/#{@query_id}") - - JSON.parse(response.body) - end - - def properties - response = get_request("/construction/index/v2/projects/#{@project_id}/indexes/#{@index_id}/queries/#{@query_id}/properties") - - JSON.parse(response.body) - end - - end - end - end -end \ No newline at end of file diff --git a/lib/autodesk/forge/api.rb b/lib/autodesk/forge/api.rb index 9179f1f..64b6e97 100644 --- a/lib/autodesk/forge/api.rb +++ b/lib/autodesk/forge/api.rb @@ -20,15 +20,6 @@ def get_request(path) http_client.get(path, headers) end - - def post_request(path, body) - headers = { - Authorization: "Bearer #{@credentials['access_token']}", - "Content-Type" => "application/json" - } - - http_client.post(path, body.to_json, headers) - end end end end \ No newline at end of file diff --git a/spec/autodesk/forge/acc_model_properties/index_spec.rb b/spec/autodesk/forge/acc_model_properties/index_spec.rb deleted file mode 100644 index d7f14e2..0000000 --- a/spec/autodesk/forge/acc_model_properties/index_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'spec_helper' - -RSpec.describe Autodesk::Forge::AccModelProperties::Index do - describe '#create' do - let(:project_id) { 'dummy_ProjectId' } - let(:urn) { 'dummy_Urn' } - - it 'sends a request to the endpoint' do - stub_hubs = stub_request(:post, "https://developer.api.autodesk.com/construction/index/v2/projects/#{project_id}/indexes:batch-status") - .with(headers: { Authorization: 'Bearer dummy-access-token', "Content-Type" => 'application/json'}, body: { versions: [{ versionUrn: urn }] }) - .to_return({ body: { data: 'dummy-data' }.to_json }) - - credentials = { 'access_token' => 'dummy-access-token' } - - index = Autodesk::Forge::AccModelProperties::Index.new(project_id: project_id, credentials: credentials) - index = index.create(urn) - - expect(stub_hubs).to have_been_requested - expect(index['data']).to be_eql('dummy-data') - end - end - - describe '#get' do - let(:project_id) { 'dummy_ProjectId' } - let(:index_id) { 'dummy_IndexId' } - - it 'sends a request to the endpoint' do - stub_hubs = stub_request(:get, "https://developer.api.autodesk.com/construction/index/v2/projects/#{project_id}/indexes/#{index_id}") - .with(headers: { Authorization: 'Bearer dummy-access-token'}) - .to_return({ body: { data: 'dummy-data' }.to_json }) - - credentials = { 'access_token' => 'dummy-access-token' } - - index = Autodesk::Forge::AccModelProperties::Index.new(project_id: project_id, index_id: index_id, credentials: credentials) - index = index.get() - - expect(stub_hubs).to have_been_requested - expect(index['data']).to be_eql('dummy-data') - end - end - -end diff --git a/spec/autodesk/forge/acc_model_properties/query_spec.rb b/spec/autodesk/forge/acc_model_properties/query_spec.rb deleted file mode 100644 index b8201eb..0000000 --- a/spec/autodesk/forge/acc_model_properties/query_spec.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'spec_helper' - -RSpec.describe Autodesk::Forge::AccModelProperties::Query do - describe '#create' do - let(:project_id) { 'dummy_ProjectId' } - let(:index_id) { 'dummy_IndexId' } - - it 'sends a request to the endpoint' do - body = { - query: "test query", - columns: "test column" - } - - stub_hubs = stub_request(:post, "https://developer.api.autodesk.com/construction/index/v2/projects/#{project_id}/indexes/#{index_id}/queries") - .with(headers: { Authorization: 'Bearer dummy-access-token', "Content-Type" => 'application/json'}, body: body) - .to_return({ body: { data: 'dummy-data' }.to_json }) - - credentials = { 'access_token' => 'dummy-access-token' } - - query = Autodesk::Forge::AccModelProperties::Query.new(project_id: project_id, index_id: index_id, credentials: credentials) - query = query.create(body) - - expect(stub_hubs).to have_been_requested - expect(query['data']).to be_eql('dummy-data') - end - end - - describe '#get' do - let(:project_id) { 'dummy_ProjectId' } - let(:index_id) { 'dummy_IndexId' } - let(:query_id) { 'dummy_QueryId' } - - it 'sends a request to the endpoint' do - stub_hubs = stub_request(:get, "https://developer.api.autodesk.com/construction/index/v2/projects/#{project_id}/indexes/#{index_id}/queries/#{query_id}") - .with(headers: { Authorization: 'Bearer dummy-access-token'}) - .to_return({ body: { data: 'dummy-data' }.to_json }) - - credentials = { 'access_token' => 'dummy-access-token' } - - query = Autodesk::Forge::AccModelProperties::Query.new(project_id: project_id, index_id: index_id, query_id: query_id, credentials: credentials) - query = query.get() - - expect(stub_hubs).to have_been_requested - expect(query['data']).to be_eql('dummy-data') - end - end - - describe '#properties' do - let(:project_id) { 'dummy_ProjectId' } - let(:index_id) { 'dummy_IndexId' } - let(:query_id) { 'dummy_QueryId' } - - it 'sends a request to the endpoint' do - stub_hubs = stub_request(:get, "https://developer.api.autodesk.com/construction/index/v2/projects/#{project_id}/indexes/#{index_id}/queries/#{query_id}/properties") - .with(headers: { Authorization: 'Bearer dummy-access-token'}) - .to_return({ body: { data: 'dummy-data' }.to_json }) - - credentials = { 'access_token' => 'dummy-access-token' } - - query = Autodesk::Forge::AccModelProperties::Query.new(project_id: project_id, index_id: index_id, query_id: query_id, credentials: credentials) - query = query.properties() - - expect(stub_hubs).to have_been_requested - expect(query['data']).to be_eql('dummy-data') - end - end - -end