shipppit-canada-post 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/canada_post.rb +3 -2
- data/lib/canada_post/client.rb +36 -8
- data/lib/canada_post/credentials.rb +2 -2
- data/lib/canada_post/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd38859443dc7b05a54e7aa1a261da790092a3ee
|
4
|
+
data.tar.gz: bd72c15948dcfed708388ebc41c29da061bc8004
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 652e4fece5355352bedcd17f1190c4ca23ae5626c805da4e998e3476665f452f6a5cbd0d4d65d8a79d1074b44c67ca37bd8445e922ffd1488968ffad58199e1e
|
7
|
+
data.tar.gz: 3403823d0b6b9c1d6f8a81ec2725c9384c3d8ed44b0a2cef6edc3179393d4746a1f46abfb986b54893968f3aaeee1ab43df7434e49e5f535452ca6a92696629f
|
data/README.md
CHANGED
@@ -201,10 +201,10 @@ Merchant information can be retrieved after registering merchant in your platfor
|
|
201
201
|
|
202
202
|
canada_post_service.create(
|
203
203
|
mobo: {
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
204
|
+
username: 'xxx',
|
205
|
+
password: 'password',
|
206
|
+
customer_number: '123456789',
|
207
|
+
contract_number: '987654321'
|
208
208
|
}
|
209
209
|
)
|
210
210
|
```
|
data/lib/canada_post.rb
CHANGED
@@ -3,9 +3,10 @@ require "canada_post/request/base"
|
|
3
3
|
require "canada_post/request/rate"
|
4
4
|
require "canada_post/request/shipping"
|
5
5
|
require "canada_post/request/registration"
|
6
|
-
require "canada_post/
|
7
|
-
require "canada_post/rate"
|
6
|
+
require "canada_post/client"
|
8
7
|
require "canada_post/credentials"
|
8
|
+
require "canada_post/rate"
|
9
|
+
require "canada_post/shipment"
|
9
10
|
|
10
11
|
module CanadaPost
|
11
12
|
# Exceptions: CandaPost::RateError
|
data/lib/canada_post/client.rb
CHANGED
@@ -5,10 +5,6 @@ module CanadaPost
|
|
5
5
|
@credentials = Credentials.new(options)
|
6
6
|
end
|
7
7
|
|
8
|
-
def rate(options={})
|
9
|
-
Request::Rate.new(@credentials, options).process_request
|
10
|
-
end
|
11
|
-
|
12
8
|
def shipment(options={})
|
13
9
|
Request::Shipment.new(@credentials, options).process_request
|
14
10
|
end
|
@@ -25,10 +21,6 @@ module CanadaPost
|
|
25
21
|
Request::Shipping.new(@credentials).get_label(label_url)
|
26
22
|
end
|
27
23
|
|
28
|
-
def details(shipping_id, mobo = @credentials.customer_number)
|
29
|
-
Request::Shipping.new(@credentials).details(shipping_id, mobo)
|
30
|
-
end
|
31
|
-
|
32
24
|
def void_shipment(shipping_id, mobo = @credentials.customer_number)
|
33
25
|
Request::Shipping.new(@credentials).void_shipping(shipping_id, mobo)
|
34
26
|
end
|
@@ -41,5 +33,41 @@ module CanadaPost
|
|
41
33
|
Request::Registration.new(@credentials).get_token
|
42
34
|
end
|
43
35
|
|
36
|
+
def get_artifact(url)
|
37
|
+
manifest = Request::Manifest.new(@credentials).get_manifest(url)
|
38
|
+
if manifest[:errors].present?
|
39
|
+
return {
|
40
|
+
status: false,
|
41
|
+
error: manifest[:errors]
|
42
|
+
}
|
43
|
+
else
|
44
|
+
artifact_link = get_artifact_link(manifest[:manifest])
|
45
|
+
artifact = Request::Manifest.new(@credentials).get_artifact(artifact_link)
|
46
|
+
return {
|
47
|
+
status: true,
|
48
|
+
artifact: artifact
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_artifact_link(manifest)
|
54
|
+
links = manifest[:links]
|
55
|
+
if links.present?
|
56
|
+
links[:link].each do |link|
|
57
|
+
if link[:rel] == 'artifact'
|
58
|
+
return link[:href]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def details(shipping_id)
|
65
|
+
Request::Shipping.new(@credentials).details(shipping_id)
|
66
|
+
end
|
67
|
+
|
68
|
+
def rate(options={})
|
69
|
+
Request::Rate.new(@credentials, options).process_request
|
70
|
+
end
|
71
|
+
|
44
72
|
end
|
45
73
|
end
|
data/lib/canada_post/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shipppit-canada-post
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olivier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|