shipping_easy 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +3 -0
- data/README.md +40 -6
- data/lib/shipping_easy/resources/base.rb +2 -2
- data/lib/shipping_easy/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: 8a863c6fb799dcc090fef67943634033515c54b6
|
4
|
+
data.tar.gz: 22875fa0281196e5642dfd7be2194155010868b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5314211e423575528620acacea83c4db39f8af1f5db519a7332901328aaa5b3f3e14ad47505b36cec708f79eaef21d55173eaa38ec7848a92691be62d9addd8b
|
7
|
+
data.tar.gz: 2770b3eceb26aa5369715209b5ea1540e7d91a0fb766e7cde303a7c2a0dedfcf6a24d4bcbc2961c0c359e778475bfd931b76cff532cc7f733f32b68ec8b90654
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -2,12 +2,16 @@
|
|
2
2
|
|
3
3
|
# ShippingEasy
|
4
4
|
|
5
|
-
This is the official wrapper for the ShippingEasy API.
|
5
|
+
This is the official wrapper for the ShippingEasy API.
|
6
6
|
|
7
|
-
|
8
|
-
* Cancelling an order before it has been shipped
|
7
|
+
The ShippingEasy API supports the following features:
|
9
8
|
|
10
|
-
|
9
|
+
* Secure, authenticated intake of orders for shipment
|
10
|
+
* Cancellation of orders that no longer need to be shipped
|
11
|
+
* A callback facility that provides shipment information (carrier, cost, tracking number, etc.) for an order
|
12
|
+
* Query capabilities to read order data from ShippingEasy
|
13
|
+
|
14
|
+
We will keep this library up to date as we expand the ShippingEasy API.
|
11
15
|
|
12
16
|
## Setup
|
13
17
|
|
@@ -62,7 +66,7 @@ The arguments for the constructor are as follows:
|
|
62
66
|
|
63
67
|
### Finding an order
|
64
68
|
|
65
|
-
To retrieve a specific order, call the find method on the Order resource class
|
69
|
+
To retrieve a specific order, call the find method on the Order resource class.
|
66
70
|
|
67
71
|
ShippingEasy::Resources::Order.find(id: 876)
|
68
72
|
|
@@ -129,7 +133,7 @@ https://gist.github.com/twmills/005b3c4ab9c85330a801
|
|
129
133
|
Your credentials could not be authenticated or the store api_key could not be found.
|
130
134
|
|
131
135
|
##### ShippingEasy::InvalidRequestError
|
132
|
-
The
|
136
|
+
The orders could not retrieved for one or more of the following reasons:
|
133
137
|
|
134
138
|
* The API timestamp could not be parsed.
|
135
139
|
|
@@ -404,6 +408,36 @@ The cancellation could not complete for one or more of the following reasons:
|
|
404
408
|
|
405
409
|
The exception will contain a message that indicates which of these conditions failed.
|
406
410
|
|
411
|
+
## Making requests via curl
|
412
|
+
First you will need to create an API signature. Concatenate these into a plaintext string using the following order:
|
413
|
+
|
414
|
+
1. Capitilized method of the request. E.g. "POST"
|
415
|
+
2. The URI path
|
416
|
+
3. The query parameters sorted alphabetically and concatenated together into a URL friendly format: param1=ABC¶m2=XYZ
|
417
|
+
4. The request body as a string if one exists
|
418
|
+
|
419
|
+
All parts are then concatenated together with an ampersand. The result resembles something like this:
|
420
|
+
|
421
|
+
"POST&/api/orders&api_key=f9a7c8ebdfd34beaf260d9b0296c7059&api_timestamp=1401803554&{\"orders\":{\"name\":\"Flip flops\",\"cost\":\"10.00\",\"shipping_cost\":\"2.00\"}}"
|
422
|
+
|
423
|
+
Finally, using your API secret encrypt the string using HMAC sha256. In ruby, it looks like this:
|
424
|
+
|
425
|
+
OpenSSL::HMAC::hexdigest("sha256", api_secret, "POST&/api/orders&api_key=f9a7c8ebdfd34beaf260d9b0296c7059&api_timestamp=1401803554&{\"orders\":{\"name\":\"Flip flops\",\"cost\":\"10.00\",\"shipping_cost\":\"2.00\"}}")
|
426
|
+
|
427
|
+
### API timestamp
|
428
|
+
You must include an API timestamp in your requests. The timestamp should be an integer representation of the current time.
|
429
|
+
|
430
|
+
### Example curl request
|
431
|
+
|
432
|
+
````shell
|
433
|
+
curl -H "Content-Type: application/json" --data @body.json "https://app.shippingeasy.com/api/stores/27aa472e16faa83dd13b7758d31974ed/orders?api_key=f9a7c8ebdfd34beaf260d9b0296c7059&api_timestamp=1401803554&api_signature=c65f43beed46e581939898a78acd10064cfa146845e97885ec02124d7ad648e4"
|
434
|
+
````
|
435
|
+
|
436
|
+
An example body.json can be found here:
|
437
|
+
|
438
|
+
https://gist.github.com/twmills/3f4636b835c611ab3f7f
|
439
|
+
|
440
|
+
|
407
441
|
## Contributing
|
408
442
|
|
409
443
|
1. Fork it
|
@@ -3,8 +3,8 @@ class ShippingEasy::Resources::Base
|
|
3
3
|
def self.command(name, command_options = {}, &block)
|
4
4
|
define_singleton_method name do |options = {}|
|
5
5
|
request_options = {}
|
6
|
-
request_options[:relative_path] = command_options.
|
7
|
-
request_options[:http_method] = command_options.
|
6
|
+
request_options[:relative_path] = command_options.fetch(:relative_path, block.call(options))
|
7
|
+
request_options[:http_method] = command_options.fetch(:http_method, :get)
|
8
8
|
request_options[:payload] = options.delete(:payload) if options.has_key?(:payload)
|
9
9
|
request_options[:params] = options unless options.nil? || options.empty?
|
10
10
|
execute_request!(request_options)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shipping_easy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ShippingEasy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|