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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +46 -2
- data/lib/inpost_uk_api/configuration.rb +1 -1
- data/lib/inpost_uk_api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ca535feef8feacc23eea8c863db020eaddce4b2e18605c8ecd902d094b19bf4
|
4
|
+
data.tar.gz: 8ae0307a7022ad320e2dc15e25bf759cf7a8681db35a07c95f98b238c44764ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4657f6257d958d733004523e7fd82f3fc61a6d563173531d49482a14072dfd1e6c3f52f23dec1c052efca0dd04b99525d86ad889833c9d4721266cd0ff3b97c4
|
7
|
+
data.tar.gz: de3171aec2b3f3a169178f39fc92d42dd478eac22b379a1fa74e6511be7cd1dbcce8d05343e1c11825329c1fb8d5423521f7bd67a0c5ad502d42b36ccb862ba3
|
data/Gemfile.lock
CHANGED
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
|
-
|
43
|
-
|
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
|
|
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.
|
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:
|
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:
|
26
|
+
version: 4.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: dotenv
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|