onesky-ruby 0.0.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +3 -0
- data/CHANGELOG.md +24 -0
- data/README.md +5 -3
- data/Rakefile +9 -1
- data/lib/onesky.rb +0 -1
- data/lib/onesky/client.rb +4 -1
- data/lib/onesky/helpers/request.rb +31 -5
- data/lib/onesky/project.rb +2 -0
- data/lib/onesky/version.rb +1 -1
- data/onesky-ruby.gemspec +7 -5
- data/spec/onesky/helpers/request_spec.rb +37 -1
- data/spec/onesky/resources/locale_spec.rb +2 -2
- data/spec/onesky/resources/project/base_spec.rb +4 -4
- data/spec/onesky/resources/project/file_spec.rb +6 -6
- data/spec/onesky/resources/project/import_task_spec.rb +4 -4
- data/spec/onesky/resources/project/order_spec.rb +6 -6
- data/spec/onesky/resources/project/translation_spec.rb +2 -2
- data/spec/onesky/resources/project_group_spec.rb +10 -10
- data/spec/onesky/resources/project_spec.rb +4 -4
- data/spec/onesky/resources/project_type_spec.rb +2 -2
- metadata +16 -17
- data/lib/onesky/restclient.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f38e7f85eb9e38ba614092251ba723cea23ecc27eac541d5d7dd2555c716d8be
|
4
|
+
data.tar.gz: 30d5e75bfe20bb3900afc8a9ab25ac7ebf40adc92e27aecbcefa62d916b85c04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4d40c63d8a041309345ded871861a4ae99ccbaa79e63ef22bd006d2edeb66aa197bd71139b393595f9f27b88080723a97bf0c960c38c258d829506422f5acaf
|
7
|
+
data.tar.gz: 9bfd0a9901fdc78b67163f0228e5e3a7adc2da2787b5f18784c405bb315edeb64a640ecb0e9e67fac604f58fefcb5d3f54e072150f609da9844b41462878381c
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
### 0.0.1 - 23-OCT-2014
|
2
|
+
|
3
|
+
* Add client for non-project resources
|
4
|
+
* project group
|
5
|
+
* project type
|
6
|
+
* locales
|
7
|
+
* project (partially)
|
8
|
+
|
9
|
+
* Add project for project based resources
|
10
|
+
* project
|
11
|
+
* file
|
12
|
+
* translation
|
13
|
+
* import task
|
14
|
+
* order
|
15
|
+
* quotation
|
16
|
+
|
17
|
+
### 1.0.0 - 31-DEC-2014
|
18
|
+
|
19
|
+
* Add custom header for OneSky
|
20
|
+
* Set as stable version
|
21
|
+
|
22
|
+
### 1.0.1 - 9-JUN-2015
|
23
|
+
|
24
|
+
* Update rest-client version
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# OneSky - Ruby client
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.org/onesky/onesky-ruby)
|
4
|
+
|
5
|
+
Ruby client for [OneSky](http://www.oneskyapp.com) [Platform API](https://github.com/onesky/api-documentation-platform)
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -45,7 +47,7 @@ p resp['data']
|
|
45
47
|
|
46
48
|
# show project details
|
47
49
|
project_id = 3
|
48
|
-
project = client.
|
50
|
+
project = client.project(project_id)
|
49
51
|
resp = JSON.parse(project.show)
|
50
52
|
p resp['data']
|
51
53
|
|
@@ -60,7 +62,7 @@ File.open('path/to/target/file', 'w') { |file| file.write(resp)}
|
|
60
62
|
|
61
63
|
## Contributing
|
62
64
|
|
63
|
-
1. Fork it ( http://github.com
|
65
|
+
1. Fork it ( http://github.com/onesky/onesky-ruby/fork )
|
64
66
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
67
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
66
68
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
data/lib/onesky.rb
CHANGED
data/lib/onesky/client.rb
CHANGED
@@ -15,11 +15,14 @@ module Onesky
|
|
15
15
|
include Resources::Project
|
16
16
|
include Helpers::Request
|
17
17
|
|
18
|
-
attr_accessor :api_key, :api_secret, :project_id
|
18
|
+
attr_accessor :api_key, :api_secret, :project_id, :plugin_code
|
19
19
|
|
20
20
|
def initialize(key, secret)
|
21
21
|
@api_key = key
|
22
22
|
@api_secret = secret
|
23
|
+
|
24
|
+
# Plugin code for custom header
|
25
|
+
@plugin_code = 'ruby-wrapper'
|
23
26
|
end
|
24
27
|
|
25
28
|
def auth_hash
|
@@ -10,35 +10,57 @@ module Helpers
|
|
10
10
|
|
11
11
|
def get(path, params = {})
|
12
12
|
uri = uri_prefix + path
|
13
|
-
|
13
|
+
params = {
|
14
|
+
content_type: :json,
|
15
|
+
params: auth_hash.merge(params),
|
16
|
+
}.merge(custom_header)
|
17
|
+
|
18
|
+
RestClient.get(uri, params) do |resp, req, result|
|
14
19
|
handle_error(resp)
|
15
20
|
end
|
16
21
|
end
|
17
22
|
|
18
23
|
def post(path, body_hash)
|
19
24
|
uri = uri_prefix + path
|
20
|
-
|
25
|
+
params = {
|
26
|
+
content_type: :json,
|
27
|
+
params: auth_hash,
|
28
|
+
}.merge(custom_header)
|
29
|
+
|
30
|
+
RestClient.post(uri, body_hash.to_json, params) do |resp, req, result|
|
21
31
|
handle_error(resp)
|
22
32
|
end
|
23
33
|
end
|
24
34
|
|
25
35
|
def post_multipart(path, body_hash)
|
26
36
|
uri = uri_prefix + path
|
27
|
-
|
37
|
+
params = {params: auth_hash}.merge(custom_header)
|
38
|
+
|
39
|
+
RestClient.post(uri, body_hash.merge({multipart: true}), params) do |resp, req, result|
|
28
40
|
handle_error(resp)
|
29
41
|
end
|
30
42
|
end
|
31
43
|
|
32
44
|
def put(path, body_hash)
|
33
45
|
uri = uri_prefix + path
|
34
|
-
|
46
|
+
params = {
|
47
|
+
content_type: :json,
|
48
|
+
params: auth_hash,
|
49
|
+
}.merge(custom_header)
|
50
|
+
|
51
|
+
RestClient.put(uri, body_hash.to_json, params) do |resp, req, result|
|
35
52
|
handle_error(resp)
|
36
53
|
end
|
37
54
|
end
|
38
55
|
|
39
56
|
def delete(path, params = {})
|
40
57
|
uri = uri_prefix + path
|
41
|
-
|
58
|
+
params = {
|
59
|
+
content_type: :json,
|
60
|
+
params: auth_hash.merge(params)
|
61
|
+
}.merge(custom_header)
|
62
|
+
|
63
|
+
RestClient.delete(uri, params) do |resp, req, result|
|
42
64
|
handle_error(resp)
|
43
65
|
end
|
44
66
|
end
|
@@ -78,5 +100,9 @@ module Helpers
|
|
78
100
|
''
|
79
101
|
end
|
80
102
|
|
103
|
+
def custom_header
|
104
|
+
{'Onesky-Plugin' => @plugin_code}
|
105
|
+
end
|
106
|
+
|
81
107
|
end
|
82
108
|
end
|
data/lib/onesky/project.rb
CHANGED
data/lib/onesky/version.rb
CHANGED
data/onesky-ruby.gemspec
CHANGED
@@ -13,15 +13,17 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "http://github.com/onesky/onesky-ruby"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
+
spec.required_ruby_version = '>= 3.0'
|
17
|
+
|
16
18
|
spec.files = `git ls-files -z`.split("\x0")
|
17
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
21
|
spec.require_paths = ["lib"]
|
20
22
|
|
21
|
-
spec.add_dependency 'rest-client', '~>
|
23
|
+
spec.add_dependency 'rest-client', '~> 2.0'
|
22
24
|
|
23
|
-
spec.add_development_dependency "bundler", "~>
|
24
|
-
spec.add_development_dependency "rake", "~>
|
25
|
-
spec.add_development_dependency "rspec", "~> 3.
|
26
|
-
spec.add_development_dependency "webmock", "~>
|
25
|
+
spec.add_development_dependency "bundler", "~> 2.2"
|
26
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.5.0"
|
28
|
+
spec.add_development_dependency "webmock", "~> 3.0"
|
27
29
|
end
|
@@ -7,8 +7,16 @@ describe 'Helpers::Request' do
|
|
7
7
|
let(:client) {Onesky::Client.new(api_key, api_secret)}
|
8
8
|
let(:project_id) {1}
|
9
9
|
let(:project) {client.project(project_id)}
|
10
|
+
let(:http_header) {{'Content-Type' => 'application/json', 'Onesky-Plugin' => 'ruby-wrapper'}}
|
10
11
|
|
11
12
|
describe '#get' do
|
13
|
+
it 'should initial request with required headers' do
|
14
|
+
stub_request(:get, full_path_with_auth_hash("/locales", api_key, api_secret))
|
15
|
+
.with(headers: http_header)
|
16
|
+
.to_return(body: "{}")
|
17
|
+
expect(client.list_locale).to be_an_instance_of(RestClient::Response)
|
18
|
+
end
|
19
|
+
|
12
20
|
it 'should raise error for error response code' do
|
13
21
|
stub_request(:get, full_path_with_auth_hash("/locales", api_key, api_secret))
|
14
22
|
.to_return(status: 400, body: {meta: {code: 400, message: 'error message'}}.to_json)
|
@@ -17,6 +25,13 @@ describe 'Helpers::Request' do
|
|
17
25
|
end
|
18
26
|
|
19
27
|
describe '#post' do
|
28
|
+
it 'should initial request with required headers' do
|
29
|
+
stub_request(:post, full_path_with_auth_hash("/project-groups", api_key, api_secret))
|
30
|
+
.with(headers: http_header)
|
31
|
+
.to_return(body: "{}")
|
32
|
+
expect(client.create_project_group({name: 'TEST'})).to be_an_instance_of(RestClient::Response)
|
33
|
+
end
|
34
|
+
|
20
35
|
it 'should return response on error' do
|
21
36
|
stub_request(:post, full_path_with_auth_hash("/project-groups", api_key, api_secret))
|
22
37
|
.to_return(status: 400, body: {meta: {code: 400, message: 'error message'}}.to_json)
|
@@ -25,14 +40,28 @@ describe 'Helpers::Request' do
|
|
25
40
|
end
|
26
41
|
|
27
42
|
describe '#post_multipart' do
|
43
|
+
it 'should initial request with required headers' do
|
44
|
+
stub_request(:post, full_path_with_auth_hash("/projects/#{project_id}/files", api_key, api_secret))
|
45
|
+
.with(headers: {'Onesky-Plugin' => 'ruby-wrapper'})
|
46
|
+
.to_return(body: "{}")
|
47
|
+
expect(project.upload_file({file: 'spec/fixture/en.yml', file_format: 'RUBY_YAML'})).to be_an_instance_of(RestClient::Response)
|
48
|
+
end
|
49
|
+
|
28
50
|
it 'should return response on error' do
|
29
51
|
stub_request(:post, full_path_with_auth_hash("/projects/#{project_id}/files", api_key, api_secret))
|
30
|
-
.to_return(status: 400, body: {meta: {code: 400, message: 'error message'}}.to_json)
|
52
|
+
.to_return(status: 400, body: {meta: {code: 400, message: 'error message'}}.to_json.to_s)
|
31
53
|
expect {project.upload_file({file: 'spec/fixture/en.yml', file_format: 'RUBY_YAML'})}.to raise_error(Onesky::Errors::BadRequestError, '400 Bad Request - error message')
|
32
54
|
end
|
33
55
|
end
|
34
56
|
|
35
57
|
describe '#put' do
|
58
|
+
it 'should initial request with required headers' do
|
59
|
+
stub_request(:put, full_path_with_auth_hash("/projects/#{project_id}", api_key, api_secret))
|
60
|
+
.with(headers: http_header)
|
61
|
+
.to_return(body: "{}")
|
62
|
+
expect(project.update({name: 'NEW NAME'})).to be_an_instance_of(RestClient::Response)
|
63
|
+
end
|
64
|
+
|
36
65
|
it 'should return response on error' do
|
37
66
|
stub_request(:put, full_path_with_auth_hash("/projects/#{project_id}", api_key, api_secret))
|
38
67
|
.to_return(status: 400, body: {meta: {code: 400, message: 'error message'}}.to_json)
|
@@ -41,6 +70,13 @@ describe 'Helpers::Request' do
|
|
41
70
|
end
|
42
71
|
|
43
72
|
describe '#delete' do
|
73
|
+
it 'should initial request with required headers' do
|
74
|
+
stub_request(:delete, full_path_with_auth_hash("/projects/#{project_id}", api_key, api_secret))
|
75
|
+
.with(headers: http_header)
|
76
|
+
.to_return(body: "{}")
|
77
|
+
expect(project.remove).to be_an_instance_of(RestClient::Response)
|
78
|
+
end
|
79
|
+
|
44
80
|
it 'should return response on error' do
|
45
81
|
stub_request(:delete, full_path_with_auth_hash("/projects/#{project_id}", api_key, api_secret))
|
46
82
|
.to_return(status: 400, body: {meta: {code: 400, message: 'error message'}}.to_json)
|
@@ -9,9 +9,9 @@ describe 'Locale' do
|
|
9
9
|
describe 'list_locale' do
|
10
10
|
it 'should list all available locales' do
|
11
11
|
stub_request(:get, full_path_with_auth_hash('/locales', api_key, api_secret))
|
12
|
-
.to_return(body: {})
|
12
|
+
.to_return(body: "{}")
|
13
13
|
response = client.list_locale
|
14
|
-
expect(response).to be_an_instance_of(
|
14
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -11,9 +11,9 @@ describe 'Project::Base' do
|
|
11
11
|
describe 'show' do
|
12
12
|
it 'should show project information' do
|
13
13
|
stub_request(:get, full_path_with_auth_hash("/projects/#{project_id}", api_key, api_secret))
|
14
|
-
.to_return(body: {})
|
14
|
+
.to_return(body: "{}")
|
15
15
|
response = project.show
|
16
|
-
expect(response).to be_an_instance_of(
|
16
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -40,9 +40,9 @@ describe 'Project::Base' do
|
|
40
40
|
describe 'list_language' do
|
41
41
|
it 'should list languages of project' do
|
42
42
|
stub_request(:get, full_path_with_auth_hash("/projects/#{project_id}/languages", api_key, api_secret))
|
43
|
-
.to_return(body: {})
|
43
|
+
.to_return(body: "{}")
|
44
44
|
response = project.list_language
|
45
|
-
expect(response).to be_an_instance_of(
|
45
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -11,9 +11,9 @@ describe 'Project::File' do
|
|
11
11
|
describe 'list_file' do
|
12
12
|
it 'should list files in project' do
|
13
13
|
stub_request(:get, full_path_with_auth_hash("/projects/#{project_id}/files", api_key, api_secret))
|
14
|
-
.to_return(body: {})
|
14
|
+
.to_return(body: "{}")
|
15
15
|
response = project.list_file
|
16
|
-
expect(response).to be_an_instance_of(
|
16
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -22,9 +22,9 @@ describe 'Project::File' do
|
|
22
22
|
|
23
23
|
it 'should upload file to project' do
|
24
24
|
stub_request(:post, full_path_with_auth_hash("/projects/#{project_id}/files", api_key, api_secret))
|
25
|
-
.to_return(body: {})
|
25
|
+
.to_return(body: "{}")
|
26
26
|
response = project.upload_file(params)
|
27
|
-
expect(response).to be_an_instance_of(
|
27
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should raise error when file does not exist' do
|
@@ -38,9 +38,9 @@ describe 'Project::File' do
|
|
38
38
|
|
39
39
|
it 'should delete file from project' do
|
40
40
|
stub_request(:delete, full_path_with_auth_hash("/projects/#{project_id}/files", api_key, api_secret) + params_as_query_string)
|
41
|
-
.to_return(body: {})
|
41
|
+
.to_return(body: "{}")
|
42
42
|
response = project.delete_file(params)
|
43
|
-
expect(response).to be_an_instance_of(
|
43
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -11,9 +11,9 @@ describe 'Project::ImportTask' do
|
|
11
11
|
describe 'list_import_task' do
|
12
12
|
it 'should list import tasks of the project' do
|
13
13
|
stub_request(:get, full_path_with_auth_hash("/projects/#{project_id}/import-tasks", api_key, api_secret))
|
14
|
-
.to_return(body: {})
|
14
|
+
.to_return(body: "{}")
|
15
15
|
response = project.list_import_task
|
16
|
-
expect(response).to be_an_instance_of(
|
16
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -22,9 +22,9 @@ describe 'Project::ImportTask' do
|
|
22
22
|
|
23
23
|
it 'should show an import task details' do
|
24
24
|
stub_request(:get, full_path_with_auth_hash("/projects/#{project_id}/import-tasks/#{import_task_id}", api_key, api_secret))
|
25
|
-
.to_return(body: {})
|
25
|
+
.to_return(body: "{}")
|
26
26
|
response = project.show_import_task(import_task_id)
|
27
|
-
expect(response).to be_an_instance_of(
|
27
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -11,9 +11,9 @@ describe 'Project::Order' do
|
|
11
11
|
describe 'list_order' do
|
12
12
|
it 'should list orders in project' do
|
13
13
|
stub_request(:get, full_path_with_auth_hash("/projects/#{project_id}/orders", api_key, api_secret))
|
14
|
-
.to_return(status: 200, body: {})
|
14
|
+
.to_return(status: 200, body: "{}")
|
15
15
|
response = project.list_order
|
16
|
-
expect(response).to be_an_instance_of(
|
16
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -22,9 +22,9 @@ describe 'Project::Order' do
|
|
22
22
|
|
23
23
|
it 'should show an order details' do
|
24
24
|
stub_request(:get, full_path_with_auth_hash("/projects/#{project_id}/orders/#{order_id}", api_key, api_secret))
|
25
|
-
.to_return(status: 200, body: {})
|
25
|
+
.to_return(status: 200, body: "{}")
|
26
26
|
response = project.show_order(order_id)
|
27
|
-
expect(response).to be_an_instance_of(
|
27
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -36,9 +36,9 @@ describe 'Project::Order' do
|
|
36
36
|
it 'should create an order' do
|
37
37
|
stub_request(:post, full_path_with_auth_hash("/projects/#{project_id}/orders", api_key, api_secret))
|
38
38
|
.with(body: params.to_json, headers: {'Content_Type' => 'application/json'})
|
39
|
-
.to_return(status: 200, body: {})
|
39
|
+
.to_return(status: 200, body: "{}")
|
40
40
|
response = project.create_order(params)
|
41
|
-
expect(response).to be_an_instance_of(
|
41
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -50,9 +50,9 @@ describe 'Project::Translation' do
|
|
50
50
|
|
51
51
|
it 'should show translation status' do
|
52
52
|
stub_request(:get, full_path_with_auth_hash("/projects/#{project_id}/translations/status", api_key, api_secret) + params_as_query_string)
|
53
|
-
.to_return(body: {})
|
53
|
+
.to_return(body: "{}")
|
54
54
|
response = project.get_translation_status(params)
|
55
|
-
expect(response).to be_an_instance_of(
|
55
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -9,9 +9,9 @@ describe 'Project Group' do
|
|
9
9
|
describe 'list_project_group' do
|
10
10
|
it 'should list all available project group' do
|
11
11
|
stub_request(:get, full_path_with_auth_hash('/project-groups', api_key, api_secret))
|
12
|
-
.to_return(body: {})
|
12
|
+
.to_return(body: "{}")
|
13
13
|
response = client.list_project_group
|
14
|
-
expect(response).to be_an_instance_of(
|
14
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -20,9 +20,9 @@ describe 'Project Group' do
|
|
20
20
|
|
21
21
|
it 'should show a project group information' do
|
22
22
|
stub_request(:get, full_path_with_auth_hash("/project-groups/#{project_group_id}", api_key, api_secret))
|
23
|
-
.to_return(body: {})
|
23
|
+
.to_return(body: "{}")
|
24
24
|
response = client.show_project_group(project_group_id)
|
25
|
-
expect(response).to be_an_instance_of(
|
25
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -32,9 +32,9 @@ describe 'Project Group' do
|
|
32
32
|
it 'should create a project group' do
|
33
33
|
stub_request(:post, full_path_with_auth_hash('/project-groups', api_key, api_secret))
|
34
34
|
.with(body: params.to_json, headers: {'Content_Type' => 'application/json'})
|
35
|
-
.to_return(body: {})
|
35
|
+
.to_return(body: "{}")
|
36
36
|
response = client.create_project_group(params)
|
37
|
-
expect(response).to be_an_instance_of(
|
37
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -43,9 +43,9 @@ describe 'Project Group' do
|
|
43
43
|
|
44
44
|
it 'should delete a project group' do
|
45
45
|
stub_request(:delete, full_path_with_auth_hash("/project-groups/#{project_group_id}", api_key, api_secret))
|
46
|
-
.to_return(body: {})
|
46
|
+
.to_return(body: "{}")
|
47
47
|
response = client.delete_project_group(project_group_id)
|
48
|
-
expect(response).to be_an_instance_of(
|
48
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -54,9 +54,9 @@ describe 'Project Group' do
|
|
54
54
|
|
55
55
|
it 'should list languages activated of a project group' do
|
56
56
|
stub_request(:get, full_path_with_auth_hash("/project-groups/#{project_group_id}/languages", api_key, api_secret))
|
57
|
-
.to_return(body: {})
|
57
|
+
.to_return(body: "{}")
|
58
58
|
response = client.list_project_group_languages(project_group_id)
|
59
|
-
expect(response).to be_an_instance_of(
|
59
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -11,9 +11,9 @@ describe 'Project' do
|
|
11
11
|
|
12
12
|
it 'should list all projects of a project group' do
|
13
13
|
stub_request(:get, full_path_with_auth_hash("/project-groups/#{project_group_id}/projects", api_key, api_secret))
|
14
|
-
.to_return(body: {})
|
14
|
+
.to_return(body: "{}")
|
15
15
|
response = client.list_project(project_group_id)
|
16
|
-
expect(response).to be_an_instance_of(
|
16
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -24,9 +24,9 @@ describe 'Project' do
|
|
24
24
|
it 'should list all projects of a project group' do
|
25
25
|
stub_request(:post, full_path_with_auth_hash("/project-groups/#{project_group_id}/projects", api_key, api_secret))
|
26
26
|
.with(body: params.to_json, headers: {'Content_Type' => 'application/json'})
|
27
|
-
.to_return(body: {})
|
27
|
+
.to_return(body: "{}")
|
28
28
|
response = client.create_project(project_group_id, params)
|
29
|
-
expect(response).to be_an_instance_of(
|
29
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -9,9 +9,9 @@ describe 'Project Type' do
|
|
9
9
|
describe 'list_project_type' do
|
10
10
|
it 'should list all available project type' do
|
11
11
|
stub_request(:get, full_path_with_auth_hash('/project-types', api_key, api_secret))
|
12
|
-
.to_return(body: {})
|
12
|
+
.to_return(body: "{}")
|
13
13
|
response = client.list_project_type
|
14
|
-
expect(response).to be_an_instance_of(
|
14
|
+
expect(response).to be_an_instance_of(RestClient::Response)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onesky-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Lam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -16,70 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.2'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '12.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '12.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.5.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.5.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '3.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '3.0'
|
83
83
|
description: Ruby wrapper for OneSky API
|
84
84
|
email:
|
85
85
|
- victorebox@yahoo.com.hk
|
@@ -89,6 +89,8 @@ extra_rdoc_files: []
|
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- CHANGELOG.md
|
92
94
|
- Gemfile
|
93
95
|
- LICENSE.txt
|
94
96
|
- README.md
|
@@ -108,7 +110,6 @@ files:
|
|
108
110
|
- lib/onesky/resources/project/translation.rb
|
109
111
|
- lib/onesky/resources/project_group.rb
|
110
112
|
- lib/onesky/resources/project_type.rb
|
111
|
-
- lib/onesky/restclient.rb
|
112
113
|
- lib/onesky/version.rb
|
113
114
|
- onesky-ruby.gemspec
|
114
115
|
- spec/fixture/en.yml
|
@@ -137,15 +138,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
138
|
requirements:
|
138
139
|
- - ">="
|
139
140
|
- !ruby/object:Gem::Version
|
140
|
-
version: '0'
|
141
|
+
version: '3.0'
|
141
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
143
|
requirements:
|
143
144
|
- - ">="
|
144
145
|
- !ruby/object:Gem::Version
|
145
146
|
version: '0'
|
146
147
|
requirements: []
|
147
|
-
|
148
|
-
rubygems_version: 2.2.2
|
148
|
+
rubygems_version: 3.2.19
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: To interact with OneSky Platform API
|
@@ -164,4 +164,3 @@ test_files:
|
|
164
164
|
- spec/onesky/resources/project_spec.rb
|
165
165
|
- spec/onesky/resources/project_type_spec.rb
|
166
166
|
- spec/spec_helper.rb
|
167
|
-
has_rdoc:
|
data/lib/onesky/restclient.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# Monkey patching RestClient::Request.process_url_params
|
2
|
-
# To support array in URL params
|
3
|
-
# RestClient.get('http://www.example.com', params: {weekday: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']})
|
4
|
-
# => GET http://www.example.com?weekday[]=Mon&weekday[]=Tue&weekday[]=Wed&weekday[]=Thu&weekday[]=Fri
|
5
|
-
|
6
|
-
module RestClient
|
7
|
-
class Request
|
8
|
-
|
9
|
-
def process_url_params url, headers
|
10
|
-
url_params = {}
|
11
|
-
headers.delete_if do |key, value|
|
12
|
-
if 'params' == key.to_s.downcase && value.is_a?(Hash)
|
13
|
-
url_params.merge! value
|
14
|
-
true
|
15
|
-
else
|
16
|
-
false
|
17
|
-
end
|
18
|
-
end
|
19
|
-
unless url_params.empty?
|
20
|
-
query_string = url_params.collect { |k, v| build_url_params(k, v) }.join('&')
|
21
|
-
url + "?#{query_string}"
|
22
|
-
else
|
23
|
-
url
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def build_url_params key, value
|
30
|
-
if value.is_a?(Array)
|
31
|
-
value.map { |v| "#{key.to_s}[]=#{CGI::escape(v.to_s)}" }.join('&')
|
32
|
-
else
|
33
|
-
"#{key.to_s}=#{CGI::escape(value.to_s)}"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|