Class: Hackle::HttpWorkspaceFetcher
- Inherits:
-
Object
- Object
- Hackle::HttpWorkspaceFetcher
- Defined in:
- lib/hackle-ruby-sdk/workspaces/http_workspace_fetcher.rb
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(config, sdk_info) ⇒ HttpWorkspaceFetcher
constructor
A new instance of HttpWorkspaceFetcher.
Constructor Details
#initialize(config, sdk_info) ⇒ HttpWorkspaceFetcher
Returns a new instance of HttpWorkspaceFetcher.
8 9 10 11 |
# File 'lib/hackle-ruby-sdk/workspaces/http_workspace_fetcher.rb', line 8 def initialize(config, sdk_info) @client = HTTP.client(config.base_uri) @headers = HTTP.sdk_headers(sdk_info) end |
Instance Method Details
#fetch ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/hackle-ruby-sdk/workspaces/http_workspace_fetcher.rb', line 13 def fetch request = Net::HTTP::Get.new('/api/v1/workspaces', @headers) response = @client.request(request) status_code = response.code.to_i HTTP.check_successful(status_code) data = JSON.parse(response.body, symbolize_names: true) Workspace.create(data) end |