shipcloud 0.4.0 → 0.5.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: 266ce622e2711933494527c5f8399799c1e6e062
4
- data.tar.gz: 0fcd0029452c89b96d40bd615fce634c848eff03
3
+ metadata.gz: b7fe7d70855f9f9d09443128ae9f2441aa1ae5d8
4
+ data.tar.gz: d10ee0cab165095c93b05f0fe89bf3013a9c0deb
5
5
  SHA512:
6
- metadata.gz: d0981f70cd47a5fcf2e21b4980f22fb371ae9caacf9a23ce03fdad61d15e4534e0f5e9b8e1691dad6460e6ff4869c5971a5359a6065435e55e5199fe4b97d4a5
7
- data.tar.gz: 6d4c9c07b4c63f935c2efe521f44e3c65e4c90299384bfd033d7a1222054c76ce91b11a7968d4a917eb89a12d758f0257736120bb70936b0c1ec400d15bc7889
6
+ metadata.gz: 1b43899286a6b7f6ec792b035c68c8544aefea872336d41e737c6b0e012ade065d580e526be7dc9412c9cfd71d6fa7778bca4bb7aa5c415e120e4d59744f3936
7
+ data.tar.gz: ffe6d71d40372d558ccf12590fb3b2699cd5cae7800d167a277c64227f9b797f5c6b7a8993b98a66a9c1d69fa636607f4eba359e43d1099afa902e7a90093c83
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - 2.1.1
6
- - 2.1.2
5
+ - 2.1.5
6
+ - 2.2.1
7
7
  - jruby
8
8
  - rbx-2
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Code Climate](https://codeclimate.com/github/webionate/shipcloud-ruby.png)](https://codeclimate.com/github/webionate/shipcloud-ruby) [![Build Status](https://travis-ci.org/webionate/shipcloud-ruby.png?branch=master)](https://travis-ci.org/webionate/shipcloud-ruby)
1
+ [![Code Climate](https://codeclimate.com/github/shipcloud/shipcloud-ruby.png)](https://codeclimate.com/github/shipcloud/shipcloud-ruby) [![Build Status](https://travis-ci.org/shipcloud/shipcloud-ruby.png?branch=master)](https://travis-ci.org/shipcloud/shipcloud-ruby)
2
2
  # shipcloud
3
3
 
4
4
  A Ruby wrapper for the shipcloud API
@@ -41,8 +41,8 @@ To create a new Shipment on the shipclod platform, you need to provide the name
41
41
  For details, see *[shipcloud API documentation on Shipments](http://docs.shipcloud.apiary.io/#shipmentresources)*
42
42
  ```
43
43
  Shipcloud::Shipment.create(
44
- carrier: 'ups',
45
- from: from-address-params,
44
+ carrier: 'ups',
45
+ from: from-address-params,
46
46
  to: to-address-params,
47
47
  package: package-params,
48
48
  create_shipping_label: true
data/lib/shipcloud.rb CHANGED
@@ -16,10 +16,12 @@ module Shipcloud
16
16
 
17
17
  autoload :Base, "shipcloud/base"
18
18
  autoload :Shipment, "shipcloud/shipment"
19
+ autoload :Carrier, "shipcloud/carrier"
19
20
 
20
21
  module Operations
21
22
  autoload :Create, "shipcloud/operations/create"
22
23
  autoload :Find, "shipcloud/operations/find"
24
+ autoload :All, "shipcloud/operations/all"
23
25
  autoload :Delete, "shipcloud/operations/delete"
24
26
  autoload :Update, "shipcloud/operations/update"
25
27
  end
@@ -0,0 +1,8 @@
1
+ module Shipcloud
2
+ class Carrier < Base
3
+ include Shipcloud::Operations::All
4
+
5
+ attr_reader :name, :display_name
6
+ end
7
+ end
8
+
@@ -0,0 +1,18 @@
1
+ module Shipcloud
2
+ module Operations
3
+ module All
4
+ module ClassMethods
5
+ # Loads all Objects of the resource
6
+ def all
7
+ response = Shipcloud.request(:get, "#{self.name.split("::").last.downcase}s", {})
8
+ response.map {|hash| self.new(hash) }
9
+ end
10
+ end
11
+
12
+ def self.included(base)
13
+ base.extend(ClassMethods)
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -26,7 +26,7 @@ module Shipcloud
26
26
  end
27
27
 
28
28
  def validate_response_data
29
- raise APIError.new(info.data["errors"]) if info.data["errors"]
29
+ raise APIError.new(info.data["errors"]) if info.data.is_a?(Hash) && info.data["errors"]
30
30
  end
31
31
  end
32
32
  end
@@ -1,3 +1,3 @@
1
1
  module Shipcloud
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/shipcloud.gemspec CHANGED
@@ -7,10 +7,10 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "shipcloud"
8
8
  spec.version = Shipcloud::VERSION
9
9
  spec.authors = ["sthollmann"]
10
- spec.email = ["stefan@webionate.de"]
10
+ spec.email = ["stefan@shipcloud.io"]
11
11
  spec.description = %q{A wrapper for the shipcloud API}
12
12
  spec.summary = %q{A wrapper for the shipcloud API}
13
- spec.homepage = "https://github.com/webionate/shipcloud-ruby"
13
+ spec.homepage = "https://github.com/shipcloud/shipcloud-ruby"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -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 "json"
22
- spec.add_development_dependency 'bundler', '~> 1.6.0'
23
- spec.add_development_dependency 'rake', '~> 10.3.0'
24
- spec.add_development_dependency 'rspec', '~> 2.99.0'
25
- spec.add_development_dependency 'webmock', '~> 1.18.0'
26
- spec.add_development_dependency 'pry', '~> 0.10.0'
21
+ spec.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.0'
22
+ spec.add_development_dependency 'bundler', '>= 1.3.0', '< 2.0'
23
+ spec.add_development_dependency 'rake', '~> 10.3'
24
+ spec.add_development_dependency 'rspec', '~> 2.99'
25
+ spec.add_development_dependency 'webmock', '~> 1.18'
26
+ spec.add_development_dependency 'pry', '~> 0.10'
27
27
  end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Shipcloud::Carrier do
4
+ describe '#initialize' do
5
+ it 'initializes all attributes correctly' do
6
+ valid_attributes = { name: 'bogus', display_name: 'Bogus Carrier' }
7
+ carrier = Shipcloud::Carrier.new(valid_attributes)
8
+
9
+ expect(carrier.name).to eq 'bogus'
10
+ expect(carrier.display_name).to eq 'Bogus Carrier'
11
+ end
12
+ end
13
+
14
+ describe '.all' do
15
+ it 'makes a new Get request using the correct API endpoint' do
16
+ expect(Shipcloud).to receive(:request).
17
+ with(:get, 'carriers', {}).and_return([])
18
+
19
+ Shipcloud::Carrier.all
20
+ end
21
+
22
+ it 'returns a list of Carrier objects' do
23
+ stub_carriers_request
24
+
25
+ carriers = Shipcloud::Carrier.all
26
+
27
+ carriers.each do |carrier|
28
+ expect(carrier).to be_a Shipcloud::Carrier
29
+ end
30
+ end
31
+
32
+ it 'initializes the Carrier objects correctly' do
33
+ stub_carriers_request
34
+ allow(Shipcloud::Carrier).to receive(:new)
35
+
36
+ carriers = Shipcloud::Carrier.all
37
+
38
+ expect(Shipcloud::Carrier).to have_received(:new).
39
+ with({ 'name' => 'carrier_1', 'display_name' => 'Carrier 1' })
40
+ expect(Shipcloud::Carrier).to have_received(:new).
41
+ with({ 'name' => 'carrier_2', 'display_name' => 'Carrier 2' })
42
+ end
43
+ end
44
+
45
+ def stub_carriers_request
46
+ allow(Shipcloud).to receive(:request).
47
+ with(:get, 'carriers', {}).
48
+ and_return(
49
+ [
50
+ { 'name' => 'carrier_1', 'display_name' => 'Carrier 1' },
51
+ { 'name' => 'carrier_2', 'display_name' => 'Carrier 2' },
52
+ ]
53
+ )
54
+ end
55
+ end
@@ -9,5 +9,16 @@ describe Shipcloud::Request::Validator do
9
9
 
10
10
  validator.validated_data_for(response).should eq "response" => "ok"
11
11
  end
12
+
13
+ it 'raises an APIError if the response contains errors' do
14
+ info = Shipcloud::Request::Info.new(:get, 'random', {})
15
+ validator = Shipcloud::Request::Validator.new info
16
+ response = OpenStruct.new(body: '{"errors":["some error"]}', code: 200)
17
+
18
+ expect { validator.validated_data_for(response) }.to raise_error(
19
+ Shipcloud::APIError,
20
+ ['some error'].to_s
21
+ )
22
+ end
12
23
  end
13
- end
24
+ end
data/spec/spec_helper.rb CHANGED
@@ -3,4 +3,10 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
3
  require 'shipcloud'
4
4
  require 'rspec'
5
5
  require "webmock/rspec"
6
- require "pry"
6
+ require "pry"
7
+
8
+ RSpec.configure do |config|
9
+ config.after(:each) do
10
+ Shipcloud.api_key = nil
11
+ end
12
+ end
metadata CHANGED
@@ -1,102 +1,114 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shipcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sthollmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-27 00:00:00.000000000 Z
11
+ date: 2015-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
17
20
  - - ">="
18
21
  - !ruby/object:Gem::Version
19
- version: '0'
22
+ version: 1.8.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.8'
24
30
  - - ">="
25
31
  - !ruby/object:Gem::Version
26
- version: '0'
32
+ version: 1.8.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 1.3.0
40
+ - - "<"
32
41
  - !ruby/object:Gem::Version
33
- version: 1.6.0
42
+ version: '2.0'
34
43
  type: :development
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
- - - "~>"
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 1.3.0
50
+ - - "<"
39
51
  - !ruby/object:Gem::Version
40
- version: 1.6.0
52
+ version: '2.0'
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: rake
43
55
  requirement: !ruby/object:Gem::Requirement
44
56
  requirements:
45
57
  - - "~>"
46
58
  - !ruby/object:Gem::Version
47
- version: 10.3.0
59
+ version: '10.3'
48
60
  type: :development
49
61
  prerelease: false
50
62
  version_requirements: !ruby/object:Gem::Requirement
51
63
  requirements:
52
64
  - - "~>"
53
65
  - !ruby/object:Gem::Version
54
- version: 10.3.0
66
+ version: '10.3'
55
67
  - !ruby/object:Gem::Dependency
56
68
  name: rspec
57
69
  requirement: !ruby/object:Gem::Requirement
58
70
  requirements:
59
71
  - - "~>"
60
72
  - !ruby/object:Gem::Version
61
- version: 2.99.0
73
+ version: '2.99'
62
74
  type: :development
63
75
  prerelease: false
64
76
  version_requirements: !ruby/object:Gem::Requirement
65
77
  requirements:
66
78
  - - "~>"
67
79
  - !ruby/object:Gem::Version
68
- version: 2.99.0
80
+ version: '2.99'
69
81
  - !ruby/object:Gem::Dependency
70
82
  name: webmock
71
83
  requirement: !ruby/object:Gem::Requirement
72
84
  requirements:
73
85
  - - "~>"
74
86
  - !ruby/object:Gem::Version
75
- version: 1.18.0
87
+ version: '1.18'
76
88
  type: :development
77
89
  prerelease: false
78
90
  version_requirements: !ruby/object:Gem::Requirement
79
91
  requirements:
80
92
  - - "~>"
81
93
  - !ruby/object:Gem::Version
82
- version: 1.18.0
94
+ version: '1.18'
83
95
  - !ruby/object:Gem::Dependency
84
96
  name: pry
85
97
  requirement: !ruby/object:Gem::Requirement
86
98
  requirements:
87
99
  - - "~>"
88
100
  - !ruby/object:Gem::Version
89
- version: 0.10.0
101
+ version: '0.10'
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
93
105
  requirements:
94
106
  - - "~>"
95
107
  - !ruby/object:Gem::Version
96
- version: 0.10.0
108
+ version: '0.10'
97
109
  description: A wrapper for the shipcloud API
98
110
  email:
99
- - stefan@webionate.de
111
+ - stefan@shipcloud.io
100
112
  executables: []
101
113
  extensions: []
102
114
  extra_rdoc_files: []
@@ -110,6 +122,8 @@ files:
110
122
  - Rakefile
111
123
  - lib/shipcloud.rb
112
124
  - lib/shipcloud/base.rb
125
+ - lib/shipcloud/carrier.rb
126
+ - lib/shipcloud/operations/all.rb
113
127
  - lib/shipcloud/operations/create.rb
114
128
  - lib/shipcloud/operations/delete.rb
115
129
  - lib/shipcloud/operations/find.rb
@@ -121,13 +135,14 @@ files:
121
135
  - lib/shipcloud/shipment.rb
122
136
  - lib/shipcloud/version.rb
123
137
  - shipcloud.gemspec
138
+ - spec/shipcloud/carrier_spec.rb
124
139
  - spec/shipcloud/request/base_spec.rb
125
140
  - spec/shipcloud/request/connection_spec.rb
126
141
  - spec/shipcloud/request/validator_spec.rb
127
142
  - spec/shipcloud/shipment_spec.rb
128
143
  - spec/shipcloud_spec.rb
129
144
  - spec/spec_helper.rb
130
- homepage: https://github.com/webionate/shipcloud-ruby
145
+ homepage: https://github.com/shipcloud/shipcloud-ruby
131
146
  licenses:
132
147
  - MIT
133
148
  metadata: {}
@@ -147,11 +162,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
162
  version: '0'
148
163
  requirements: []
149
164
  rubyforge_project:
150
- rubygems_version: 2.3.0
165
+ rubygems_version: 2.4.6
151
166
  signing_key:
152
167
  specification_version: 4
153
168
  summary: A wrapper for the shipcloud API
154
169
  test_files:
170
+ - spec/shipcloud/carrier_spec.rb
155
171
  - spec/shipcloud/request/base_spec.rb
156
172
  - spec/shipcloud/request/connection_spec.rb
157
173
  - spec/shipcloud/request/validator_spec.rb