inpost_uk_api 0.2.0 → 0.2.3

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: 10a4173972e8bd2ba21493c62ddc469b523e8d5ce5e06f5dcc533037556eacfa
4
- data.tar.gz: 30fab7c9f3b86cf249153c55c8d7559c1dfaad953d41ea32579ee00425698054
3
+ metadata.gz: e1e46d004bdcb1a0136cfb1cc2d45ddfd453eb96b0db8ee6849a1eb7ffb63e24
4
+ data.tar.gz: 38499fbfd6de6a2ceafa8dd847f41b32d5a22f6ef7d8a27573747e09cd9846db
5
5
  SHA512:
6
- metadata.gz: '059e75f99fcb60131555089b9d5210e01ab002e3db6b1a4cdcea818ddb1856a76a728d930bf6b0bafb64e5cd2036dba3acfa41826d65cd9b7d6e8d30f7ba6608'
7
- data.tar.gz: c488fb94973cdb6a92f93c4a0285f9b304878b14e8dca6efde76dd051337340a9146128304b1646045969d92e63b469451ef6d09c2cbcdea16a3b5c79a639cea
6
+ metadata.gz: ef748dc4b5389b7b500ebba112b8700c572689dc8cd012bdfe6461e66a3bc62678b55ab4f4b9f4706d4b317300799f7ea60b211bd732a9b542a25a1530a1d4a6
7
+ data.tar.gz: bee2421b55233a6c5ea6567227a564357036cd62c16cc218f9cc6ce8c6109ce44aeeded74cc951789c27ba09581597b7e9024aa4f76c987e043779ef9c6d9a52
data/.env.sample ADDED
@@ -0,0 +1,3 @@
1
+ RETAILER=
2
+ API_TOKEN=
3
+ SITE=
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- inpost_uk_api (0.1.1)
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
@@ -1,9 +1,5 @@
1
1
  # InPostUKAPI
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/inpost_uk_api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
2
+ This is an unofficial Ruby API wrapper for `https://developers.inpost.co.uk/`
7
3
  ## Installation
8
4
 
9
5
  Add this line to your application's Gemfile:
@@ -21,8 +17,57 @@ Or install it yourself as:
21
17
  $ gem install inpost_uk_api
22
18
 
23
19
  ## Usage
20
+ ### Returns
21
+ #### Create a Returns Request
22
+ Doc: https://developers.inpost.co.uk/#operation/createReturns
23
+ ```ruby
24
+ re = InPostUKAPI::Return.new(
25
+ sender_email: "sender@postco.co",
26
+ sender_phone: "7999999999",
27
+ size: "A",
28
+ customer_reference: "customer reference number",
29
+ show_quick_send_code: "true"
30
+ )
31
+ re.save
32
+
33
+ re.id # => "CS0000000009778"
34
+ re.status # => "customer_delivering
35
+ ```
36
+ #### Get Returns QR Code
37
+ Doc: https://developers.inpost.co.uk/#operation/getReturnsLabel
38
+ ```ruby
39
+ label = InPostUKAPI::ReturnLabel.find("CS0000000009778")
40
+ label # => a pdf blob string
41
+
42
+ begin
43
+ invalid_label = InPostUKAPI::ReturnLabel.find("CS00000000ABC")
44
+ rescue ActiveResource::ResourceNotFound => e
45
+ e.response.body # => "{\"status_code\":404,\"error_code\":\"return_not_found\",\"message\":\"Return CS0000000009778d not found.\",\"errors\":{}}"
24
46
 
25
- TODO: Write usage instructions here
47
+ # activeresource version >= 6.0.0
48
+ e.message # => Return CS00000000ABC not found.
49
+
50
+ # activeresource version < 6.0.0
51
+ e.message # => Failed. Response code = 200. Response message = OK.
52
+ end
53
+ ```
54
+ ### Request Tracking Data
55
+ This endpoint only available for PROD labels.
56
+
57
+ The tracking data you got might not be the right one if you are querying using the tracking id from the staging server.
58
+
59
+ Doc: https://developers.inpost.co.uk/#operation/getTracking
60
+ ```ruby
61
+ tracking = InPostUKAPI::Tracking.find("CS0000000009778")
62
+ CS0000000009778_trackings = tracking.CS0000000009778
63
+ CS0000000009778_trackings.first.ts # => "29/03/2021 15:43:56pm"
64
+ CS0000000009778_trackings.first.description # => "Ready For Dispatch"
65
+
66
+ # Can query for multiple parcels by separating the ids by ";".
67
+ tracking = InPostUKAPI::Tracking.where("CS0000000009778;CS0000000009777;CSDDD")
68
+ CSDDD_trackings = tracking.CSDDD
69
+ CSDDD_trackings.error # => "No events found for consignment CSDDD"
70
+ ```
26
71
 
27
72
  ## Development
28
73
 
@@ -30,9 +75,21 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
30
75
 
31
76
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
77
 
78
+ ### Pending Endpoints
79
+ - [ ] [APM Locations API](https://developers.inpost.co.uk/#tag/APM-Locations-API)
80
+ - [ ] [getAPMLocations](https://developers.inpost.co.uk/#operation/getAPMLocations)
81
+ - [ ] [Address to Locker Label Creation](https://developers.inpost.co.uk/#tag/Address-to-Locker-Label-Creation)
82
+ - [ ] [Create Address to Locker Label](https://developers.inpost.co.uk/#operation/addressToLocker)
83
+ - [ ] [Pay for Address to Locker Parcel](https://developers.inpost.co.uk/#operation/addressToLockerPayment)
84
+ - [ ] [Get Address to Locker Parcel Label](https://developers.inpost.co.uk/#operation/getAddressToLockerLabel)
85
+ - [ ] [Locker to Address Label Creation](https://developers.inpost.co.uk/#tag/Locker-to-Address-Label-Creation)
86
+ - [ ] [Create Locker to Address Label](https://developers.inpost.co.uk/#operation/lockerToAdddress)
87
+ - [ ] [Pay for Locker to Address Parcel](https://developers.inpost.co.uk/#operation/lockerToAddressPayment)
88
+ - [ ] [Get Locker to Address Parcel Label](https://developers.inpost.co.uk/#operation/getLockerToAddressLabel)
89
+
33
90
  ## Contributing
34
91
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/inpost_uk_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/inpost_uk_api/blob/main/CODE_OF_CONDUCT.md).
92
+ Bug reports and pull requests are welcome on GitHub at https://github.com/postco/inpost_uk_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/postco/inpost_uk_api/blob/main/CODE_OF_CONDUCT.md).
36
93
 
37
94
  ## License
38
95
 
@@ -40,4 +97,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
97
 
41
98
  ## Code of Conduct
42
99
 
43
- Everyone interacting in the InPostUKAPI project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/inpost_uk_api/blob/main/CODE_OF_CONDUCT.md).
100
+ Everyone interacting in the InPostUKAPI project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/postco/inpost_uk_api/blob/main/CODE_OF_CONDUCT.md).
data/bin/setup CHANGED
@@ -3,6 +3,8 @@ set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
+ cp .env.sample .env
7
+
6
8
  bundle install
7
9
 
8
10
  # Do any other automated setup that you need to do here
@@ -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
@@ -7,9 +7,10 @@ module InPostUKAPI
7
7
  DEFAULT_ATTRS = {
8
8
  sender_email: 'customer_email@inpost.co.uk',
9
9
  sender_phone: '7999999999',
10
- size: 'A',
11
10
  customer_reference: 'customer reference number',
12
- show_quick_send_code: 'true'
11
+ show_quick_send_code: 'false'
13
12
  }
13
+
14
+ validates_presence_of :sender_email, :sender_phone
14
15
  end
15
16
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InPostUKAPI
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inpost_uk_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Chong
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-12 00:00:00.000000000 Z
11
+ date: 2022-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -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
@@ -143,6 +143,7 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
+ - ".env.sample"
146
147
  - ".rspec"
147
148
  - ".standard.yml"
148
149
  - CHANGELOG.md