flowcommerce 0.0.10 → 0.0.11
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/README.md +19 -25
- data/lib/clients/flow_catalog_v0_client.rb +96 -70
- data/lib/clients/flow_common_v0_client.rb +11 -11
- data/lib/clients/flow_experience_v0_client.rb +1040 -0
- data/lib/flow_commerce/client.rb +56 -1
- data/lib/flowcommerce.rb +1 -0
- metadata +3 -2
data/lib/flow_commerce/client.rb
CHANGED
@@ -1,6 +1,47 @@
|
|
1
1
|
module FlowCommerce
|
2
2
|
|
3
|
-
|
3
|
+
DEFAULT_TOKEN_FILE_LOCATION = "~/.flow/token"
|
4
|
+
|
5
|
+
# Creates a new instance of the flow cient, using standard
|
6
|
+
# conventions to identify the API TOKEN, checking in order:
|
7
|
+
#
|
8
|
+
# 1. an environment variable named FLOW_TOKEN
|
9
|
+
# 2. an environment variable named FLOW_TOKEN_FILE containing
|
10
|
+
# the path of the file with the token in it
|
11
|
+
#
|
12
|
+
# @param module e.g. catalog, experience - this is temporary
|
13
|
+
# until Flow consolidates its APIs into a single domain
|
14
|
+
def FlowCommerce.instance(app)
|
15
|
+
token = ENV['FLOW_TOKEN'].to_s.strip
|
16
|
+
|
17
|
+
if token.empty?
|
18
|
+
file = ENV['FLOW_TOKEN_FILE'].to_s.strip
|
19
|
+
if file.empty?
|
20
|
+
file = DEFAULT_TOKEN_FILE_LOCATION
|
21
|
+
end
|
22
|
+
path = File.expand_path(file)
|
23
|
+
|
24
|
+
if !File.exists?(path)
|
25
|
+
raise "File %s does not exist. You can specify environment variable FLOW_TOKEN or FLOW_TOKEN_FILE to explicitly provide the token" % path
|
26
|
+
end
|
27
|
+
|
28
|
+
token = IO.read(path).strip
|
29
|
+
if token.empty?
|
30
|
+
raise "File %s did not contain an API Token" % path
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
case app
|
35
|
+
when "catalog"
|
36
|
+
FlowCommerce.catalog_client(token, opts = {})
|
37
|
+
when "experience"
|
38
|
+
FlowCommerce.experience_client(token, opts = {})
|
39
|
+
else
|
40
|
+
raise "Invalid module name[%s]" % app
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def FlowCommerce.catalog_client(token, opts = {})
|
4
45
|
if token.empty?
|
5
46
|
raise "ERROR: Token is required"
|
6
47
|
end
|
@@ -15,5 +56,19 @@ module FlowCommerce
|
|
15
56
|
end
|
16
57
|
end
|
17
58
|
|
59
|
+
def FlowCommerce.experience_client(token, opts = {})
|
60
|
+
if token.empty?
|
61
|
+
raise "ERROR: Token is required"
|
62
|
+
end
|
63
|
+
|
64
|
+
base_url = opts[:base_url].to_s.strip
|
65
|
+
auth = Io::Flow::Experience::V0::HttpClient::Authorization.basic(token)
|
66
|
+
|
67
|
+
if base_url.empty?
|
68
|
+
Io::Flow::Experience::V0::Client.at_base_url(:authorization => auth)
|
69
|
+
else
|
70
|
+
Io::Flow::Experience::V0::Client.new(base_url, :authorization => auth)
|
71
|
+
end
|
72
|
+
end
|
18
73
|
|
19
74
|
end
|
data/lib/flowcommerce.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flowcommerce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flow Commerce, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- README.md
|
48
48
|
- lib/clients/flow_catalog_v0_client.rb
|
49
49
|
- lib/clients/flow_common_v0_client.rb
|
50
|
+
- lib/clients/flow_experience_v0_client.rb
|
50
51
|
- lib/flow_commerce/client.rb
|
51
52
|
- lib/flowcommerce.rb
|
52
53
|
homepage: https://github.com/flowcommerce/ruby-sdk
|