pandexio 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +78 -0
- data/Rakefile +9 -0
- data/lib/{module.rb → pandexio.rb} +0 -0
- data/test/test_header_signing.rb +1 -2
- data/test/test_query_string_signing.rb +1 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11d0ae57fd72c6ad78f545813885cccb081cf150
|
4
|
+
data.tar.gz: b1576bd2c258a559c6e95b699dd685ed650dbacb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91fe4c64f017985f897317166cdf8793d27d548e6907c29ccd970b670a8cd591fb97cc47cc763335d627e50b7b65b03161f28ba139d59efcb369dbbf73d087cc
|
7
|
+
data.tar.gz: 65cb8adb6cfa96e496d43cd5eb2af3c121cf4097e76e66f435d29ae4f4012cc00ce988fe1533a563ebc0ccb1fcb8bf7cea3e9bb75e5e0c4ef45c2a0da56f9de3
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
#Pandexio SDK for Ruby
|
2
|
+
|
3
|
+
##Overview
|
4
|
+
This Pandexio SDK enables Ruby server applications to easily generate signed requests that can be consumed by the Pandexio REST API (https://platform.pandexio.com) and the Pandexio Hosted Model (https://hosted.pandexio.com).
|
5
|
+
|
6
|
+
##Definitions
|
7
|
+
|
8
|
+
###Pandexio::Request
|
9
|
+
- type - class
|
10
|
+
- attributes:
|
11
|
+
- method - required. The request HTTP verb (GET, POST, PUT, PATCH, DELETE).
|
12
|
+
- path - required. The path part of the request URL (e.g., /v2/documents/a4df7a95-d1f6-4664-b208-74568990bd15).
|
13
|
+
- query_parameters - optional. A hash containing the query parameters (e.g., { "coverSize" => "xl" }).
|
14
|
+
- headers - required. A hash containing the headers (e.g., { "Host" => "platform.pandexio.com" }). Host header must be included.
|
15
|
+
- payload - optional. UTF-8 encoded request body. Only applicable for POST, PUT, and PATCH requests.
|
16
|
+
|
17
|
+
###Pandexio::SigningOptions
|
18
|
+
- type - class
|
19
|
+
- attributes:
|
20
|
+
- algorithm - required. The HMAC algorithm to use. Choose from any specified in
|
21
|
+
- Pandexio::SigningAlgorithms::PDX_HMAC_MD5 - MD5 HMAC
|
22
|
+
- Pandexio::SigningAlgorithms::PDX_HMAC_SHA1 - SHA1 HMAC
|
23
|
+
- Pandexio::SigningAlgorithms::PDX_HMAC_SHA256 - SHA256 HMAC
|
24
|
+
- Pandexio::SigningAlgorithms::PDX_HMAC_SHA384 - SHA384 HMAC
|
25
|
+
- Pandexio::SigningAlgorithms::PDX_HMAC_SHA512 - SHA512 HMAC
|
26
|
+
- mechanism - required. Specifies which signing mechanism to use. Signing mechanisms include:
|
27
|
+
- Pandexio::SigningMechanisms::QUERY_STRING - Sign the request using query string parameters
|
28
|
+
- Pandexio::SigningMechanisms::HEADER - Sign the request using headers
|
29
|
+
- domain_id - required. Public API key.
|
30
|
+
- domain_key - required. Shared secret API key used to generate HMAC signatures.
|
31
|
+
- date - required. ISO8601 date/time when the request was made.
|
32
|
+
- expires - required. Number of seconds before the request signature expires.
|
33
|
+
- originator - required. The name of the application, feature, etc. making the request.
|
34
|
+
- email_address - required. The email address of the user making the request.
|
35
|
+
- display_name - required. The display name of the user making the request.
|
36
|
+
- profile_image - optional. The profile image thumbnail, either data URL or HTTP URL of the user making the request.
|
37
|
+
|
38
|
+
###Pandexio::to_authorized_request
|
39
|
+
- type - method
|
40
|
+
- arguments
|
41
|
+
- Pandexio::Request *normalized_request* - A non-signed request containing information about the request to be made.
|
42
|
+
- Pandexio::SigningOptions *signing_options* - The details specifying how to sign the *normalized_request*
|
43
|
+
- result
|
44
|
+
- Pandexio::Request *authorized_request* - A signed request containing information about the request to be made as well as signing information as headers or query string parameters, depending on the *signing_options*.
|
45
|
+
|
46
|
+
##Signing a Request
|
47
|
+
Take the following steps to create a signed Pandexio request.
|
48
|
+
|
49
|
+
1. Create an instance of Pandexio::Request containing details of the request to be made, the *normalized_request*.
|
50
|
+
2. Create an instance of Pandexio::SigningOptions. These *signing_options* specify the SDK will sign the request.
|
51
|
+
3. Call Pandexio::to_authorized_request, passing in the *normalized_request* and the *signing_options*.
|
52
|
+
4. Build an HTTP request using the Pandexio::Request, *authorized_request*, returned by Pandexio::to_authorized_request and make the HTTP request using the HTTP client of choice.
|
53
|
+
|
54
|
+
##All Together
|
55
|
+
Here's an example showing the generation of a signed Pandexio request to retrieve an extra large document cover thumbnail for a given document:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
require 'pandexio'
|
59
|
+
|
60
|
+
normalized_request = Pandexio::Request.new(
|
61
|
+
:method => "GET",
|
62
|
+
:path => "/v2/documents/a4df7a95-d1f6-4664-b208-74568990bd15/cover",
|
63
|
+
:query_parameters => { "coverSize" => "xl" },
|
64
|
+
:headers => { "Host" => "platform.pandexio.com" })
|
65
|
+
|
66
|
+
signing_options = Pandexio::SigningOptions.new(
|
67
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
68
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
69
|
+
:domain_id => "1234567890",
|
70
|
+
:domain_key => "asdfjklqwerzxcv",
|
71
|
+
:date => Time.utc(2015, 6, 10, 13, 22, 46),
|
72
|
+
:expires => 90,
|
73
|
+
:originator => "Demo",
|
74
|
+
:email_address => "terry@contoso.com",
|
75
|
+
:display_name => "Terry Contoso")
|
76
|
+
|
77
|
+
authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
78
|
+
```
|
data/Rakefile
ADDED
File without changes
|
data/test/test_header_signing.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
|
-
require_relative '../lib/
|
2
|
+
require_relative '../lib/pandexio.rb'
|
3
3
|
|
4
4
|
describe Pandexio do
|
5
5
|
before do
|
@@ -24,7 +24,6 @@ describe Pandexio do
|
|
24
24
|
:display_name => "Anonymous")
|
25
25
|
|
26
26
|
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
27
|
-
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
28
27
|
end
|
29
28
|
|
30
29
|
describe "#header_signing" do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
|
-
require_relative '../lib/
|
2
|
+
require_relative '../lib/pandexio.rb'
|
3
3
|
|
4
4
|
describe Pandexio do
|
5
5
|
before do
|
@@ -24,7 +24,6 @@ describe Pandexio do
|
|
24
24
|
:display_name => "Anonymous")
|
25
25
|
|
26
26
|
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
27
|
-
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
28
27
|
end
|
29
28
|
|
30
29
|
describe "#query_string_signing" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pandexio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Varilone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Pandexio SDK for Ruby
|
14
14
|
email: bvarilone@gmail.com
|
@@ -16,7 +16,9 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
-
-
|
19
|
+
- README.md
|
20
|
+
- Rakefile
|
21
|
+
- lib/pandexio.rb
|
20
22
|
- lib/request.rb
|
21
23
|
- lib/signing_algorithms.rb
|
22
24
|
- lib/signing_attributes.rb
|