onesky-ruby 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07702d69f7f7c3651594e79cf6dbd6e3bdf35205
4
- data.tar.gz: f4bfd6c6a08a1b2ad6747d317bd676bd175989e7
3
+ metadata.gz: 09e973e24c4068bc89d7dd58f2f6b1ce604b35ec
4
+ data.tar.gz: 20410a85721b13430449b86e3c3e6de496ee1c8c
5
5
  SHA512:
6
- metadata.gz: 6f995fba3cc6aa9486a467474ed9b041fb4132a1222c3a787699ed0da7a718aa74e6bb1d8a3aa4869036a8cfbc0c47579dcdb9327a11351cdb7f4abcab1bdffa
7
- data.tar.gz: 182b75526c85377c628084bf88920d605aff30af196e90fd1514b89c5835e531a6f5f4f4bb18f41022933b34e0d7e1162a3ca8180eaed6b42f1e41f8ed9b296b
6
+ metadata.gz: df3f27cdc68d27a9dda0f720a5071bdc4e4dab4dc03533297d88919a5c97b72229478161842bda57703351199f4a88b063b9a729cd2b641d74b33c913fee7755
7
+ data.tar.gz: 33cecc02abc92d9bde46515a6e1443045ce2dc1576e60551c730027be71aa50eb6e4d2db3d9786c87e9f138b24fa25f60c31b6e2a76f0a23d1a83887c279e2a9
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
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
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # OneSky - Ruby client
2
2
 
3
+ [![Build Status](https://travis-ci.org/onesky/onesky-ruby.svg)](https://travis-ci.org/onesky/onesky-ruby)
4
+
3
5
  Ruby client for [OneSky](http://www.oneskyapp.com) [Platform API](/onesky/api-documentation-platform)
4
6
 
5
7
  ## Installation
@@ -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/<my-github-username>/onesky-ruby/fork )
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
@@ -1 +1,9 @@
1
- require "bundler/gem_tasks"
1
+ begin
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec) { |t| t.verbose = false }
5
+
6
+ task :default => :spec
7
+ rescue LoadError
8
+ p "no rspec available"
9
+ end
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
- RestClient.get(uri, params: auth_hash.merge(params)) do |resp, req, result|
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
- RestClient.post(uri, body_hash.to_json, content_type: :json, params: auth_hash) do |resp, req, result|
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
- RestClient.post(uri, body_hash.merge({multipart: true}), params: auth_hash) do |resp, req, result|
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
- RestClient.put(uri, body_hash.to_json, content_type: :json, params: auth_hash) do |resp, req, result|
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
- RestClient.delete(uri, params: auth_hash.merge(params)) do |resp, req, result|
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
@@ -22,6 +22,8 @@ module Onesky
22
22
  def initialize(client, id)
23
23
  @client = client
24
24
  @project_id = id
25
+
26
+ @plugin_code = client.plugin_code
25
27
  end
26
28
 
27
29
  private
@@ -1,3 +1,3 @@
1
1
  module Onesky
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
data/onesky-ruby.gemspec CHANGED
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'rest-client', '~> 1.7'
21
+ spec.add_dependency 'rest-client', '~> 1.7.2'
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.5"
24
24
  spec.add_development_dependency "rake", "~> 10.3"
25
- spec.add_development_dependency "rspec", "~> 3.1"
26
- spec.add_development_dependency "webmock", "~> 1.19"
25
+ spec.add_development_dependency "rspec", "~> 3.1.0"
26
+ spec.add_development_dependency "webmock", "~> 1.19.0"
27
27
  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(Hash)
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(Hash)
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,6 +40,13 @@ 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(Hash)
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
52
  .to_return(status: 400, body: {meta: {code: 400, message: 'error message'}}.to_json)
@@ -33,6 +55,13 @@ describe 'Helpers::Request' do
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(Hash)
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(Hash)
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)
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: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Lam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-23 00:00:00.000000000 Z
11
+ date: 2014-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: 1.7.2
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: '1.7'
26
+ version: 1.7.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.1'
61
+ version: 3.1.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: '3.1'
68
+ version: 3.1.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: '1.19'
75
+ version: 1.19.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: '1.19'
82
+ version: 1.19.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