inpost_uk_api 0.2.1 → 0.2.4

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
  SHA256:
3
- metadata.gz: 6dda1cffb81e05a5949565a77a66129e85ee1265abd65ecb0c153f1d8f43f724
4
- data.tar.gz: bd4b3ea8f0c8f10efeda5c2857a1f7a7da9ded6c81ddcb5716a3de5f3af3e66f
3
+ metadata.gz: 8ca535feef8feacc23eea8c863db020eaddce4b2e18605c8ecd902d094b19bf4
4
+ data.tar.gz: 8ae0307a7022ad320e2dc15e25bf759cf7a8681db35a07c95f98b238c44764ca
5
5
  SHA512:
6
- metadata.gz: 7d5e923cbcc947a6bf8420498757998bfaf6cb3f640ba8bc78fcc731a484cfa4e9910265c725ed70e39452a6215ac5ade56c88a75e8947f297a5a7ce8ff33cf4
7
- data.tar.gz: 77559295091da1a0c4fedcad2fbd4aa2a6d68203aaaad0d0f4cb1335b27cf657aa7ed04600244819180f04e416f4c7895976c45c93aa69a606793609e65265f4
6
+ metadata.gz: 4657f6257d958d733004523e7fd82f3fc61a6d563173531d49482a14072dfd1e6c3f52f23dec1c052efca0dd04b99525d86ad889833c9d4721266cd0ff3b97c4
7
+ data.tar.gz: de3171aec2b3f3a169178f39fc92d42dd478eac22b379a1fa74e6511be7cd1dbcce8d05343e1c11825329c1fb8d5423521f7bd67a0c5ad502d42b36ccb862ba3
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- inpost_uk_api (0.2.0)
5
- activeresource (>= 6.0.0)
4
+ inpost_uk_api (0.2.1)
5
+ activeresource (>= 4.1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -17,6 +17,15 @@ Or install it yourself as:
17
17
  $ gem install inpost_uk_api
18
18
 
19
19
  ## Usage
20
+ ### Configurations
21
+ ```ruby
22
+ InPostUKAPI.configure do |config|
23
+ config.site = ENV['SITE']
24
+ config.retailer = ENV['RETAILER']
25
+ config.api_token = ENV['API_TOKEN']
26
+ end
27
+ ```
28
+
20
29
  ### Returns
21
30
  #### Create a Returns Request
22
31
  Doc: https://developers.inpost.co.uk/#operation/createReturns
@@ -38,9 +47,24 @@ Doc: https://developers.inpost.co.uk/#operation/getReturnsLabel
38
47
  ```ruby
39
48
  label = InPostUKAPI::ReturnLabel.find("CS0000000009778")
40
49
  label # => a pdf blob string
50
+
51
+ begin
52
+ invalid_label = InPostUKAPI::ReturnLabel.find("CS00000000ABC")
53
+ rescue ActiveResource::ResourceNotFound => e
54
+ e.response.body # => "{\"status_code\":404,\"error_code\":\"return_not_found\",\"message\":\"Return CS0000000009778d not found.\",\"errors\":{}}"
55
+
56
+ # activeresource version >= 6.0.0
57
+ e.message # => Return CS00000000ABC not found.
58
+
59
+ # activeresource version < 6.0.0
60
+ e.message # => Failed. Response code = 200. Response message = OK.
61
+ end
41
62
  ```
42
- #### Request Tracking Data (only for PROD)
43
- The tracking data you got might not be the right one if you are querying using the Return id from the staging server.
63
+ ### Request Tracking Data
64
+ This endpoint only available for PROD labels.
65
+
66
+ The tracking data you got might not be the right one if you are querying using the tracking id from the staging server.
67
+
44
68
  Doc: https://developers.inpost.co.uk/#operation/getTracking
45
69
  ```ruby
46
70
  tracking = InPostUKAPI::Tracking.find("CS0000000009778")
@@ -53,6 +77,26 @@ tracking = InPostUKAPI::Tracking.where("CS0000000009778;CS0000000009777;CSDDD")
53
77
  CSDDD_trackings = tracking.CSDDD
54
78
  CSDDD_trackings.error # => "No events found for consignment CSDDD"
55
79
  ```
80
+ ### Temporary credentials
81
+ You can use the `InPostUKAPI::Base.with_account` method which accept a block to set a temporary credentials. Useful for platform to set different InPost account for each retailer.
82
+
83
+ Applicable to [Create a Returns Request](#create-a-returns-request) and [Get Returns QR Code](#get-returns-qr-code).
84
+ ```ruby
85
+ re, label = nil
86
+ account = {retailer: "temp@postco.co", api_token: "temp token 123" }
87
+ InPostUKAPI::Base.with_account(account) do
88
+ re = InPostUKAPI::Return.new(
89
+ sender_email: "sender@postco.co",
90
+ sender_phone: "7999999999",
91
+ size: "A",
92
+ customer_reference: "customer reference number",
93
+ show_quick_send_code: "true"
94
+ )
95
+ re.save
96
+ label = InPostUKAPI::ReturnLabel.find(re.id)
97
+ end
98
+ ```
99
+
56
100
 
57
101
  ## Development
58
102
 
@@ -1,6 +1,6 @@
1
1
  module InPostUKAPI
2
2
  class Configuration
3
- attr_accessor :site, :retailer
3
+ attr_accessor :site, :retailer, :api_token
4
4
  end
5
5
 
6
6
  class << self
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InPostUKAPI
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inpost_uk_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Chong
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0
19
+ version: 4.1.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: 6.0.0
26
+ version: 4.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dotenv
29
29
  requirement: !ruby/object:Gem::Requirement