whitehouse 0.0.1

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.
@@ -0,0 +1,134 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://sandbox.apps.whcc.com/api/Catalog?access_token=101024773634
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - Whitehouse Ruby Gem 0.0.1
14
+ Authorization:
15
+ - Token token="101024773634"
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Cache-Control:
24
+ - no-cache
25
+ Pragma:
26
+ - no-cache
27
+ Content-Type:
28
+ - application/json
29
+ Expires:
30
+ - "-1"
31
+ Server:
32
+ - Microsoft-IIS/8.5
33
+ X-Aspnetmvc-Version:
34
+ - '5.1'
35
+ X-Aspnet-Version:
36
+ - 4.0.30319
37
+ X-Powered-By:
38
+ - ASP.NET
39
+ Date:
40
+ - Mon, 27 Oct 2014 20:41:37 GMT
41
+ Content-Length:
42
+ - '132'
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"ErrorNumber":"403.01","Message":"You are not authorized to access
46
+ the resource you requested: Expired or incorrect access token."}'
47
+ http_version:
48
+ recorded_at: Mon, 27 Oct 2014 20:41:38 GMT
49
+ - request:
50
+ method: get
51
+ uri: https://sandbox.apps.whcc.com/api/AccessToken?consumer_key=FA2DBC52662850A7B53B&consumer_secret=rPTa7aIydCI=&grant_type=consumer_credentials
52
+ body:
53
+ encoding: US-ASCII
54
+ string: ''
55
+ headers:
56
+ Accept:
57
+ - application/json
58
+ User-Agent:
59
+ - Whitehouse Ruby Gem 0.0.1
60
+ Accept-Encoding:
61
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
62
+ response:
63
+ status:
64
+ code: 200
65
+ message: OK
66
+ headers:
67
+ Cache-Control:
68
+ - private
69
+ Content-Type:
70
+ - application/json
71
+ Server:
72
+ - Microsoft-IIS/8.5
73
+ X-Aspnetmvc-Version:
74
+ - '5.1'
75
+ X-Aspnet-Version:
76
+ - 4.0.30319
77
+ X-Powered-By:
78
+ - ASP.NET
79
+ Date:
80
+ - Mon, 27 Oct 2014 20:41:39 GMT
81
+ Content-Length:
82
+ - '175'
83
+ body:
84
+ encoding: UTF-8
85
+ string: '{"ClientId":"2791999","ConsumerKey":"FA2DBC52662850A7B53B","EffectiveDate":"10\/27\/2014
86
+ 3:41:39 PM CST","ExpirationDate":"10\/27\/2014 4:41:39 PM CST","Token":"786691958342"}'
87
+ http_version:
88
+ recorded_at: Mon, 27 Oct 2014 20:41:40 GMT
89
+ - request:
90
+ method: get
91
+ uri: https://sandbox.apps.whcc.com/api/Catalog?access_token=786691958342
92
+ body:
93
+ encoding: US-ASCII
94
+ string: ''
95
+ headers:
96
+ Accept:
97
+ - application/json
98
+ User-Agent:
99
+ - Whitehouse Ruby Gem 0.0.1
100
+ Authorization:
101
+ - Token token="786691958342"
102
+ Accept-Encoding:
103
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
104
+ response:
105
+ status:
106
+ code: 200
107
+ message: OK
108
+ headers:
109
+ Cache-Control:
110
+ - no-cache
111
+ Pragma:
112
+ - no-cache
113
+ Content-Type:
114
+ - application/json
115
+ Expires:
116
+ - "-1"
117
+ Server:
118
+ - Microsoft-IIS/8.5
119
+ X-Aspnetmvc-Version:
120
+ - '5.1'
121
+ X-Aspnet-Version:
122
+ - 4.0.30319
123
+ X-Powered-By:
124
+ - ASP.NET
125
+ Date:
126
+ - Mon, 27 Oct 2014 20:41:46 GMT
127
+ Content-Length:
128
+ - '2'
129
+ body:
130
+ encoding: UTF-8
131
+ string: '{}'
132
+ http_version:
133
+ recorded_at: Mon, 27 Oct 2014 20:41:46 GMT
134
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,103 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://sandbox.apps.whcc.com/api/OrderImport?access_token=101024773634
6
+ body:
7
+ encoding: UTF-8
8
+ string: "-------------RubyMultipartPost\r\nContent-Disposition: form-data; name=\"entry\";
9
+ filename=\"entry.json20141024-52208-10sofzc\"\r\nContent-Length: 734\r\nContent-Type:
10
+ application/json\r\nContent-Transfer-Encoding: binary\r\n\r\n{\"EntryID\":\"123abc\",\"Orders\":[{\"DropShipFlag\":1,\"FromAddressValue\":1,\"OrderAttributes\":[{\"AttributeUID\":95},{\"AttributeUID\":97}],\"SequenceNumber\":1,\"ShipToAddress\":{\"Name\":\"Bill
11
+ Adama\",\"Addr1\":\"2840 Lone Oak Parkway\",\"Addr2\":null,\"City\":\"Eagan\",\"State\":\"MN\",\"Zip\":55121,\"Country\":\"US\"},\"OrderItems\":[{\"ItemAssets\":[{\"AssetPath\":\"http://lab.whcc.com/ApostleIslandMarina.jpg\",\"PrintedFileName\":\"\",\"ImageHash\":\"60ee3ed946def317eae764516b727f50\",\"DP2NodeID\":10000,\"OffsetX\":50,\"OffsetY\":50,\"X\":50,\"Y\":50,\"ZoomX\":100,\"ZoomY\":100,\"ImageRotation\":0,\"isCoverAsset\":false,\"isJacketAsset\":false,\"ColorCorrect\":false}],\"ItemAttributes\":[{\"AttributeUID\":5},{\"AttributeUID\":1}],\"ProductUID\":3,\"Quantity\":1,\"LineItemID\":0,\"LayoutRotation\":null}]}]}\r\n-------------RubyMultipartPost--\r\n\r\n"
12
+ headers:
13
+ Accept:
14
+ - application/json
15
+ User-Agent:
16
+ - Whitehouse Ruby Gem 0.0.1
17
+ Content-Type:
18
+ - multipart/form-data; boundary=-----------RubyMultipartPost
19
+ Content-Length:
20
+ - '985'
21
+ Authorization:
22
+ - Token token="101024773634"
23
+ Accept-Encoding:
24
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
25
+ response:
26
+ status:
27
+ code: 200
28
+ message: OK
29
+ headers:
30
+ Cache-Control:
31
+ - no-cache
32
+ Pragma:
33
+ - no-cache
34
+ Content-Type:
35
+ - application/json
36
+ Expires:
37
+ - "-1"
38
+ Server:
39
+ - Microsoft-IIS/8.5
40
+ X-Aspnetmvc-Version:
41
+ - '5.1'
42
+ X-Aspnet-Version:
43
+ - 4.0.30319
44
+ X-Powered-By:
45
+ - ASP.NET
46
+ Date:
47
+ - Fri, 24 Oct 2014 21:24:28 GMT
48
+ Content-Length:
49
+ - '489'
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"Account":"27919","ConfirmationID":"c0f4087d-2866-48eb-8d34-a7aa4d22911a","EntryID":"123abc","Key":"756216BF68455757BCED","NumberOfOrders":1,"Orders":[{"LineItems":[{"ID":"1"}],"Note":"","Products":[{"Price":"1.10","ProductDescription":"Photo
53
+ Print 8x10","Quantity":1},{"Price":"10.90","ProductDescription":"Minimum Order
54
+ Charge","Quantity":1}],"SequenceNumber":"1","SubTotal":"12.00","Tax":"0.85","Total":"12.85"}],"Received":"10/24/2014
55
+ 4:10:26 PM Central Time"}'
56
+ http_version:
57
+ recorded_at: Fri, 24 Oct 2014 21:24:28 GMT
58
+ - request:
59
+ method: post
60
+ uri: https://sandbox.apps.whcc.com/api/OrderImport/Submit/ecb9d9e6-42e0-4a69-ad7e-9996dfec343d
61
+ body:
62
+ encoding: UTF-8
63
+ string: "-------------RubyMultipartPost\r\nContent-Disposition: form-data; name=\"access_token\"\r\n\r\n101024773634\r\n-------------RubyMultipartPost--\r\n"
64
+ headers:
65
+ Accept:
66
+ - application/json
67
+ Content-Type:
68
+ - multipart/form-data; boundary=-----------RubyMultipartPost
69
+ Accept-Encoding:
70
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
71
+ User-Agent:
72
+ - Ruby
73
+ response:
74
+ status:
75
+ code: 200
76
+ message: OK
77
+ headers:
78
+ Cache-Control:
79
+ - no-cache
80
+ Pragma:
81
+ - no-cache
82
+ Content-Type:
83
+ - application/json
84
+ Expires:
85
+ - "-1"
86
+ Server:
87
+ - Microsoft-IIS/8.5
88
+ X-Aspnetmvc-Version:
89
+ - '5.1'
90
+ X-Aspnet-Version:
91
+ - 4.0.30319
92
+ X-Powered-By:
93
+ - ASP.NET
94
+ Date:
95
+ - Fri, 24 Oct 2014 21:29:15 GMT
96
+ Content-Length:
97
+ - '162'
98
+ body:
99
+ encoding: UTF-8
100
+ string: '{"Confirmation":"Entry ID=ecb9d9e6-42e0-4a69-ad7e-9996dfec343d: Confirmed order submitted.","ConfirmedOrders":1,"Received":"10\/24\/2014 4:36:44 PM Central Time"}'
101
+ http_version:
102
+ recorded_at: Fri, 24 Oct 2014 21:29:15 GMT
103
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,98 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://sandbox.apps.whcc.com/api/callback/create?access_token=101024773634
6
+ body:
7
+ encoding: UTF-8
8
+ string: callbackUri=http%3A%2F%2Fexample.com%2Fwebhook
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - Whitehouse Ruby Gem 0.0.1
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ Authorization:
17
+ - Token token="125853637777"
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Cache-Control:
26
+ - no-cache
27
+ Pragma:
28
+ - no-cache
29
+ Content-Type:
30
+ - application/json
31
+ Expires:
32
+ - "-1"
33
+ Server:
34
+ - Microsoft-IIS/8.5
35
+ X-Aspnetmvc-Version:
36
+ - '5.1'
37
+ X-Aspnet-Version:
38
+ - 4.0.30319
39
+ X-Powered-By:
40
+ - ASP.NET
41
+ Date:
42
+ - Mon, 27 Oct 2014 15:35:27 GMT
43
+ Content-Length:
44
+ - '187'
45
+ body:
46
+ encoding: UTF-8
47
+ string: '{"Created":"10\/27\/2014","Verifier":"A unique verification code posted
48
+ to your callback URI. To complete the verification send it back to us by calling
49
+ the callback\/verify API method."}'
50
+ http_version:
51
+ recorded_at: Mon, 27 Oct 2014 15:35:33 GMT
52
+ - request:
53
+ method: post
54
+ uri: https://sandbox.apps.whcc.com/api/callback/verify
55
+ body:
56
+ encoding: US-ASCII
57
+ string: access_token=532742632759&verifier=3f8afc02-cd26-423d-a2d0-d6b9d6c1f1bf
58
+ headers:
59
+ Accept:
60
+ - text/xml
61
+ Accept-Encoding:
62
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
63
+ User-Agent:
64
+ - Ruby
65
+ Content-Type:
66
+ - application/x-www-form-urlencoded
67
+ response:
68
+ status:
69
+ code: 200
70
+ message: OK
71
+ headers:
72
+ Cache-Control:
73
+ - no-cache
74
+ Pragma:
75
+ - no-cache
76
+ Content-Type:
77
+ - text/xml
78
+ Expires:
79
+ - "-1"
80
+ Server:
81
+ - Microsoft-IIS/8.5
82
+ X-Aspnetmvc-Version:
83
+ - '5.1'
84
+ X-Aspnet-Version:
85
+ - 4.0.30319
86
+ X-Powered-By:
87
+ - ASP.NET
88
+ Date:
89
+ - Mon, 27 Oct 2014 15:38:04 GMT
90
+ Content-Length:
91
+ - '197'
92
+ body:
93
+ encoding: UTF-8
94
+ string: <CallbackVerifyStatus xmlns="http://apps.whcc.com/api/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Status>Verified</Status><Updated>10/27/2014
95
+ 10:38:04 AM</Updated></CallbackVerifyStatus>
96
+ http_version:
97
+ recorded_at: Mon, 27 Oct 2014 15:38:10 GMT
98
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Whitehouse::Client::Catalog do
4
+ before do
5
+ Whitehouse.reset!
6
+ end
7
+
8
+ let(:client) { Whitehouse::Client.new(access_token: '101024773634') }
9
+
10
+ describe "#request_catalog", vcr: {cassette_name: 'catalog', record: :new_episodes} do
11
+ let(:catalog) { client.request_catalog }
12
+ let(:categories) { catalog["Categories"] }
13
+ it 'fetches the product catalog' do
14
+ expect(categories.length).to eql(2)
15
+ expect(WebMock).to have_requested(:get, /\/api\/Catalog/)
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Whitehouse::Client::Order, vcr: {cassette_name: 'order', record: :new_episodes} do
4
+ before do
5
+ Whitehouse.reset!
6
+ end
7
+
8
+ let(:client) { Whitehouse::Client.new(access_token: '101024773634') }
9
+ let(:address) { Whitehouse::Order::Address.new("Bill Adama","2840 Lone Oak Parkway",nil,"Eagan","MN",55121) }
10
+ let(:order_item) { Whitehouse::Order::OrderItem.new(3,"http://lab.whcc.com/ApostleIslandMarina.jpg", "60ee3ed946def317eae764516b727f50", [5,1]) }
11
+ let(:order) {
12
+ Whitehouse::Order.new do |order|
13
+ order.entry_id = "123abc"
14
+ order.order_attributes = [95,97]
15
+ order.to_address = address
16
+ order.add_item(order_item)
17
+ end
18
+ }
19
+
20
+ describe "#submit_order" do
21
+ it "returns a confirmation code via api" do
22
+ res = client.submit_order(order)
23
+ expect(res.length).to eq(36)
24
+ expect(WebMock).to have_requested(:post, /\/api\/OrderImport/)
25
+ end
26
+ end
27
+
28
+ describe "#confirm_order" do
29
+ let(:confirmation_code) { "ecb9d9e6-42e0-4a69-ad7e-9996dfec343d" }
30
+ it "confirms order via api" do
31
+ res = client.confirm_order(confirmation_code)
32
+ expect(res).to be_truthy
33
+ expect(WebMock).to have_requested(:post, /\/api\/OrderImport\/Submit\/#{confirmation_code}/)
34
+ end
35
+ end
36
+
37
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Whitehouse::Client::Webhook, vcr: {cassette_name: 'webhook', record: :new_episodes} do
4
+ before do
5
+ Whitehouse.reset!
6
+ end
7
+
8
+ let(:client) { Whitehouse::Client.new(access_token: '101024773634') }
9
+
10
+ describe "#create_webhook" do
11
+ let(:uri) { "http://example.com/webhook" }
12
+ it "returns a confirmation code via api" do
13
+ res = client.create_webhook(uri)
14
+ expect(res).to be_truthy
15
+ expect(WebMock).to have_requested(:post, /\/api\/callback\/create/)
16
+ end
17
+ end
18
+
19
+ describe "#verify_webhook" do
20
+ let(:verifier) { "3f8afc02-cd26-423d-a2d0-d6b9d6c1f1bf" }
21
+ it "verifies webhook" do
22
+ res = client.verify_webhook(verifier)
23
+ expect(res).to be_truthy
24
+ expect(WebMock).to have_requested(:post, /\/api\/callback\/verify/)
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Whitehouse::Client, vcr: {cassette_name: 'client', record: :new_episodes} do
4
+ before do
5
+ Whitehouse.reset!
6
+ end
7
+
8
+ let(:client) { Whitehouse::Client.new(access_token: '101024773634') }
9
+
10
+ describe "authentication" do
11
+ it "gets a new access token if expired" do
12
+ client.get "Catalog"
13
+ expect(WebMock).to have_requested(:get, /AccessToken/)
14
+ expect(WebMock).to have_requested(:get, /Catalog/).twice
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ require 'pry'
2
+ require 'dotenv'
3
+ Dotenv.load '.env.test'
4
+ require 'whitehouse'
5
+ require 'vcr'
6
+ require 'webmock/rspec'
7
+
8
+ VCR.configure do |c|
9
+ c.cassette_library_dir = 'spec/cassettes'
10
+ c.hook_into :webmock
11
+ c.configure_rspec_metadata!
12
+ end
13
+
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe Whitehouse, vcr: {cassette_name: 'client', record: :new_episodes} do
4
+ before do
5
+ Whitehouse.reset!
6
+ end
7
+
8
+ after do
9
+ Whitehouse.reset!
10
+ end
11
+
12
+ it "sets defaults" do
13
+ Whitehouse::Configurable.keys.each do |key|
14
+ expect(Whitehouse.instance_variable_get(:"@#{key}")).to eq(Whitehouse::Default.send(key))
15
+ end
16
+ end
17
+
18
+ describe ".client" do
19
+ it "creates a Whitehouse::Client" do
20
+ expect(Whitehouse.client).to be_kind_of Whitehouse::Client
21
+ end
22
+ it "caches the client when the same options are passed" do
23
+ expect(Whitehouse.client).to eq(Whitehouse.client)
24
+ end
25
+ it "returns a fresh client when options are not the same" do
26
+ client = Whitehouse.client
27
+ Whitehouse.user_agent = "A different ruby gem"
28
+ client_two = Whitehouse.client
29
+ client_three = Whitehouse.client
30
+ expect(client).not_to eq(client_two)
31
+ expect(client_three).to eq(client_two)
32
+ end
33
+ end
34
+
35
+ describe ".configure" do
36
+ Whitehouse::Configurable.keys.each do |key|
37
+ it "sets the #{key.to_s.gsub('_',' ')}" do
38
+ Whitehouse.configure do |config|
39
+ config.send("#{key}=", key)
40
+ end
41
+ expect(Whitehouse.instance_variable_get(:"@#{key}")).to eq(key)
42
+ end
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'whitehouse/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "whitehouse"
8
+ spec.version = Whitehouse::VERSION
9
+ spec.authors = ["travisdahlke"]
10
+ spec.email = ["travis.dahlke@whcc.com"]
11
+ spec.summary = %q{White House Custom Colour API Client}
12
+ spec.description = %q{A client gem for submitting orders to the White House Custom Colour API}
13
+ spec.homepage = "http://github.com/whcc/whcc_ruby"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "dotenv"
25
+ spec.add_development_dependency "pry"
26
+ spec.add_development_dependency "vcr"
27
+ spec.add_development_dependency "webmock"
28
+
29
+ spec.add_dependency "faraday"
30
+ spec.add_dependency "faraday_middleware"
31
+ spec.add_dependency "hashie"
32
+ end