shipppit-canada-post 0.5.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00ff5aab5456ba9e2c713466439d72de463a8a9a
4
- data.tar.gz: 6e68939726c48b6b49272421d8118fd62f5a0cdb
3
+ metadata.gz: fd38859443dc7b05a54e7aa1a261da790092a3ee
4
+ data.tar.gz: bd72c15948dcfed708388ebc41c29da061bc8004
5
5
  SHA512:
6
- metadata.gz: 267d00ca8147cd62d41788b8f20a7ee49732c6ce6e79af1da8921e8908523758a49fe1bf68c07f2c00aa39a3393c8614791566549c5ff1bc47c67cf634f39b45
7
- data.tar.gz: 386c4d513111ef8fd82e423eedf62e7ed9a2b957dc752af9084a2765e4a991bc1891a72a3c9f0f8deacd752d308529a4b93efa5d089ff741843a0f916c41c1cf
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
- username: 'xxx',
205
- password: 'password',
206
- customer_number: '123456789',
207
- contract_number: '987654321'
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/shipment"
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
@@ -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
@@ -9,9 +9,9 @@ module CanadaPost
9
9
  @username = options[:username]
10
10
  @password = options[:password]
11
11
  @customer_number = options[:customer_number]
12
- @mode = options[:mode]
12
+ @mode = options[:mode] || "development"
13
13
  end
14
14
 
15
15
  end
16
16
 
17
- end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module CanadaPost
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
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.0
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-03 00:00:00.000000000 Z
11
+ date: 2016-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty