Skip to content

Commit

Permalink
Merge pull request #35 from szprutamich/master
Browse files Browse the repository at this point in the history
Version 0.6.0
  • Loading branch information
lastverb authored Nov 17, 2023
2 parents edc7675 + 26b1d59 commit 32c7f48
Show file tree
Hide file tree
Showing 43 changed files with 133 additions and 252 deletions.
82 changes: 39 additions & 43 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
testdroid-api-client (0.5.0)
testdroid-api-client (0.6.0)
deep_merge (~> 1.2)
faraday (~> 0.17, >= 0.17)
oauth2 (~> 1.4)
Expand All @@ -10,68 +10,64 @@ PATH
GEM
remote: https://rubygems.org/
specs:
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
bump (0.8.0)
crack (0.4.3)
safe_yaml (~> 1.0.0)
deep_merge (1.2.1)
diff-lcs (1.2.5)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
faraday (0.17.3)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
bump (0.10.0)
crack (0.4.5)
rexml
deep_merge (1.2.2)
diff-lcs (1.5.0)
domain_name (0.6.20231109)
faraday (0.17.6)
multipart-post (>= 1.2, < 3)
hashdiff (1.0.0)
hashdiff (1.0.1)
http-accept (1.7.0)
http-cookie (1.0.3)
http-cookie (1.0.5)
domain_name (~> 0.5)
jwt (2.2.1)
mime-types (3.3.1)
jwt (2.7.1)
mime-types (3.5.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.0512)
mime-types-data (3.2023.1003)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
multipart-post (2.3.0)
netrc (0.11.0)
oauth2 (1.4.4)
faraday (>= 0.8, < 2.0)
oauth2 (1.4.11)
faraday (>= 0.17.3, < 3.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
public_suffix (4.0.1)
rack (2.2.3)
rake (12.3.3)
rack (>= 1.2, < 4)
public_suffix (5.0.3)
rack (3.0.8)
rake (13.1.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-collection_matchers (1.1.2)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-collection_matchers (1.2.1)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-mocks (3.5.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
safe_yaml (1.0.5)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.7)
vcr (5.0.0)
webmock (3.7.6)
addressable (>= 2.3.6)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
vcr (5.1.0)
webmock (3.19.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
yard (0.9.20)
yard (0.9.34)

PLATFORMS
ruby
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[![Gem Version](https://badge.fury.io/rb/testdroid-api-client.svg)](https://badge.fury.io/rb/testdroid-api-client)
[![Build Status](https://travis-ci.org/bitbar/testdroid-api-client-ruby.svg?branch=master)](https://travis-ci.org/bitbar/testdroid-api-client-ruby)


Testdroid API Client for Ruby
Expand Down Expand Up @@ -79,4 +78,11 @@ files.list({:limit => 40,:filter => "s_direction_eq_INPUT"}).each {
|f| puts "File id: #{f.id} name: #{f.name}" }
```

See https://cloud.bitbar.com/cloud/swagger-ui.html for more details about API V2
See https://cloud.bitbar.com/cloud/swagger-ui.html for more details about API V2, make sure you are logged in.

Local development
=================

1. Install ruby
2. `bundle install`
3. Run tests: `rspec`, remove `spec/fixtures/cassettes` if you want to execute real Http requests
1 change: 0 additions & 1 deletion lib/testdroid-api-client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
require 'timeout'
require 'set'

require 'testdroid_api/client'
require 'testdroid_api/apikey_client'

require 'testdroid_api/cloud_resource'
Expand Down
45 changes: 43 additions & 2 deletions lib/testdroid_api/apikey_client.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module TestdroidAPI
class ApikeyClient < Client

class ApikeyClient

attr_reader :config
attr_accessor :logger
Expand All @@ -23,12 +24,16 @@ def authorize

if @cloud_user.nil?
@cloud_user = TestdroidAPI::User.new("/#{API_VERSION}/me", self).refresh
@cloud_user = TestdroidAPI::User.new("/#{API_VERSION}/users/#{@cloud_user.id}", self).refresh

end
@cloud_user
end

def mime_for(path)
mime = MIME::Types.type_for path
mime.empty? ? 'text/plain' : mime[0].content_type
end

# Basic methods

def request_factory(method, uri, http_params = {}, headers = {})
Expand Down Expand Up @@ -116,5 +121,41 @@ def download(uri, file_name, params = {}, http_params = {})
end
end

# Resources

# public read-only

def info
TestdroidAPI::CloudResource.new("/#{API_VERSION}/info", self, "info")
end

def devices
TestdroidAPI::Devices.new("/#{API_VERSION}/devices", self)
end

def label_groups
TestdroidAPI::LabelGroups.new("/#{API_VERSION}/label-groups", self)
end

# user read-write

def me
TestdroidAPI::User.new("/#{API_VERSION}/me", self).load
end

def properties
TestdroidAPI::Properties.new("/#{API_VERSION}/properties", self)
end

def device_session_connections
TestdroidAPI::DeviceSessionConnections.new("/#{API_VERSION}/device-session-connections", self)
end

# admin only

def admin
TestdroidAPI::Admin.new("/#{API_VERSION}/admin", self)
end

end
end
161 changes: 0 additions & 161 deletions lib/testdroid_api/client.rb

This file was deleted.

4 changes: 1 addition & 3 deletions sample/sample.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require 'testdroid-api-client'

client = TestdroidAPI::Client.new(ENV['BITBAR_USERNAME'], ENV['BITBAR_PASSWORD'])
#or using api key:
#client = TestdroidAPI::ApikeyClient.new(ENV['BITBAR_APIKEY'])
client = TestdroidAPI::ApikeyClient.new(ENV['BITBAR_APIKEY'])
#to use private cloud specify cloud url as:
#client = TestdroidAPI::Client.new('API_KEY', 'https://customer.bitbar.com')
user = client.authorize
Expand Down
2 changes: 1 addition & 1 deletion spec/client_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe TestdroidAPI::Client do
describe TestdroidAPI::ApikeyClient do
context "#initialize" do
it "uses cloud.bitbar.com as default host" do
expect(client.instance_variable_get('@cloud_url')).to eq "https://cloud.bitbar.com"
Expand Down
2 changes: 1 addition & 1 deletion spec/device_groups_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

it 'create device group' do
VCR.use_cassette(File.basename(__FILE__).split('_spec')[0] + '_create') do
device_group = @user.device_groups.create({:params => {:displayName => 'Empty'}})
device_group = @user.device_groups.create({:displayName => 'Empty'})
DG_ID = device_group.id
end
end
Expand Down
Loading

0 comments on commit 32c7f48

Please sign in to comment.