attune 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/attune/default.rb +4 -0
- data/lib/attune/gzip_request.rb +27 -0
- data/lib/attune/models/anonymous_result.rb +1 -1
- data/lib/attune/models/batch_ranking_request.rb +2 -2
- data/lib/attune/models/batch_ranking_result.rb +2 -2
- data/lib/attune/models/blacklist.rb +25 -25
- data/lib/attune/models/blacklist_get_response.rb +1 -1
- data/lib/attune/models/blacklist_params.rb +25 -25
- data/lib/attune/models/blacklist_save_response.rb +1 -1
- data/lib/attune/models/customer.rb +1 -1
- data/lib/attune/models/ranked_entities.rb +9 -9
- data/lib/attune/models/ranking_params.rb +28 -28
- data/lib/attune/models/scope_entry.rb +3 -3
- data/lib/attune/version.rb +1 -1
- data/spec/remote_spec.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55fd8fc4869a5683e96320760ec40769e6ad8eae
|
4
|
+
data.tar.gz: 3670d480e007e4c3359f60aca54ccc358bfc5ebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f3791fa61216413b48d19ff413976fe20ae0d3268d139c36ea753922e990d7912dab40aaab568996a0d0f6e9ec224ca04d69212b4b09f84945e34f292a15dd8
|
7
|
+
data.tar.gz: 76be0940a93b17b72dd30267214c63116c94d6b8a8173b79a7663a08987fe2f8842210f598b14e8613c6f3846dfb9b9647b4f850d3398ed7e6135c83b99c1655
|
data/lib/attune/default.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'attune/param_flattener'
|
2
2
|
require "attune/call_dropping"
|
3
3
|
require "attune/json_logger"
|
4
|
+
require "attune/gzip_request"
|
4
5
|
require "attune/net_http_persistent"
|
5
6
|
|
6
7
|
module Attune
|
@@ -28,6 +29,9 @@ module Attune
|
|
28
29
|
# Log all requests
|
29
30
|
builder.use Attune::JsonLogger
|
30
31
|
|
32
|
+
# Gzip requests, Faraday handles responses automatically
|
33
|
+
builder.use Attune::GzipRequest
|
34
|
+
|
31
35
|
# Raise exceptions for HTTP 4xx/5xx
|
32
36
|
builder.response :raise_error
|
33
37
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Attune
|
2
|
+
class GzipRequest < Faraday::Middleware
|
3
|
+
CONTENT_TYPE = 'Content-Type'.freeze
|
4
|
+
CONTENT_ENCODING = 'Content-Encoding'.freeze
|
5
|
+
MIME_TYPE = 'application/json'.freeze
|
6
|
+
ENCODING_TYPE = 'gzip'.freeze
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
if has_body?(env) && is_json?(env)
|
10
|
+
wio = StringIO.new("w")
|
11
|
+
w_gz = Zlib::GzipWriter.new(wio)
|
12
|
+
w_gz.write env[:body]
|
13
|
+
w_gz.close
|
14
|
+
env[:body] = wio.string
|
15
|
+
env[:request_headers][CONTENT_ENCODING] = ENCODING_TYPE
|
16
|
+
end
|
17
|
+
@app.call env
|
18
|
+
end
|
19
|
+
def is_json?(env)
|
20
|
+
env[:request_headers][CONTENT_TYPE] == MIME_TYPE
|
21
|
+
end
|
22
|
+
def has_body?(env)
|
23
|
+
body = env[:body] and !(body.respond_to?(:to_str) and body.empty?)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Attune
|
2
2
|
module Model
|
3
|
-
#
|
3
|
+
# Array of the parameters specified for a ranking request
|
4
4
|
#
|
5
|
-
# @attr [Array<Attune::Model::RankingParams>] requests
|
5
|
+
# @attr [Array<Attune::Model::RankingParams>] requests
|
6
6
|
class BatchRankingRequest
|
7
7
|
attr_accessor :requests
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Attune
|
2
2
|
module Model
|
3
|
-
#
|
3
|
+
# Array of ranking results.
|
4
4
|
#
|
5
|
-
# @attr [Array<Attune::Model::RankedEntities>] results
|
5
|
+
# @attr [Array<Attune::Model::RankedEntities>] results Array of rankings in order of the parameters provided as input.
|
6
6
|
class BatchRankingResult
|
7
7
|
attr_accessor :results
|
8
8
|
|
@@ -2,15 +2,15 @@ module Attune
|
|
2
2
|
module Model
|
3
3
|
#
|
4
4
|
#
|
5
|
-
# @attr [String] id
|
6
|
-
# @attr [Array<String>] ids
|
7
|
-
# @attr [
|
8
|
-
# @attr [
|
9
|
-
# @attr [String]
|
10
|
-
# @attr [String]
|
11
|
-
# @attr [String]
|
12
|
-
# @attr [
|
13
|
-
# @attr [String]
|
5
|
+
# @attr [String] id
|
6
|
+
# @attr [Array<String>] ids
|
7
|
+
# @attr [String] consumer
|
8
|
+
# @attr [String] entity_type
|
9
|
+
# @attr [String] start_date
|
10
|
+
# @attr [String] end_date
|
11
|
+
# @attr [String] created_at
|
12
|
+
# @attr [Boolean] disabled
|
13
|
+
# @attr [Array<String>] scope
|
14
14
|
class Blacklist
|
15
15
|
attr_accessor :id
|
16
16
|
|
@@ -18,12 +18,6 @@ module Attune
|
|
18
18
|
attr_accessor :ids
|
19
19
|
|
20
20
|
|
21
|
-
attr_accessor :disabled
|
22
|
-
|
23
|
-
|
24
|
-
attr_accessor :scope
|
25
|
-
|
26
|
-
|
27
21
|
attr_accessor :consumer
|
28
22
|
|
29
23
|
|
@@ -39,6 +33,12 @@ module Attune
|
|
39
33
|
attr_accessor :created_at
|
40
34
|
|
41
35
|
|
36
|
+
attr_accessor :disabled
|
37
|
+
|
38
|
+
|
39
|
+
attr_accessor :scope
|
40
|
+
|
41
|
+
|
42
42
|
def initialize(attributes = {})
|
43
43
|
return if attributes.empty?
|
44
44
|
# Workaround since JSON.parse has accessors as strings rather than symbols
|
@@ -47,13 +47,6 @@ module Attune
|
|
47
47
|
if value.is_a?(Array)
|
48
48
|
@ids = value
|
49
49
|
|
50
|
-
end
|
51
|
-
# Workaround since JSON.parse has accessors as strings rather than symbols
|
52
|
-
@disabled = attributes["disabled"] || attributes[:"disabled"]
|
53
|
-
value = attributes["scope"] || attributes[:"scope"]
|
54
|
-
if value.is_a?(Array)
|
55
|
-
@scope = value
|
56
|
-
|
57
50
|
end
|
58
51
|
# Workaround since JSON.parse has accessors as strings rather than symbols
|
59
52
|
@consumer = attributes["consumer"] || attributes[:"consumer"]
|
@@ -65,6 +58,13 @@ module Attune
|
|
65
58
|
@end_date = attributes["endDate"] || attributes[:"end_date"]
|
66
59
|
# Workaround since JSON.parse has accessors as strings rather than symbols
|
67
60
|
@created_at = attributes["createdAt"] || attributes[:"created_at"]
|
61
|
+
# Workaround since JSON.parse has accessors as strings rather than symbols
|
62
|
+
@disabled = attributes["disabled"] || attributes[:"disabled"]
|
63
|
+
value = attributes["scope"] || attributes[:"scope"]
|
64
|
+
if value.is_a?(Array)
|
65
|
+
@scope = value
|
66
|
+
|
67
|
+
end
|
68
68
|
|
69
69
|
|
70
70
|
end
|
@@ -85,13 +85,13 @@ module Attune
|
|
85
85
|
ATTRIBUTE_MAP = {
|
86
86
|
:id => :id,
|
87
87
|
:ids => :ids,
|
88
|
-
:disabled => :disabled,
|
89
|
-
:scope => :scope,
|
90
88
|
:consumer => :consumer,
|
91
89
|
:entity_type => :entityType,
|
92
90
|
:start_date => :startDate,
|
93
91
|
:end_date => :endDate,
|
94
|
-
:created_at => :createdAt
|
92
|
+
:created_at => :createdAt,
|
93
|
+
:disabled => :disabled,
|
94
|
+
:scope => :scope
|
95
95
|
|
96
96
|
}
|
97
97
|
end
|
@@ -2,42 +2,33 @@ module Attune
|
|
2
2
|
module Model
|
3
3
|
#
|
4
4
|
#
|
5
|
-
# @attr [
|
6
|
-
# @attr [String]
|
7
|
-
# @attr [
|
8
|
-
# @attr [String]
|
9
|
-
# @attr [
|
10
|
-
# @attr [
|
5
|
+
# @attr [String] entity_type
|
6
|
+
# @attr [Array<String>] ids
|
7
|
+
# @attr [Boolean] disabled
|
8
|
+
# @attr [Array<String>] scope
|
9
|
+
# @attr [String] active_from
|
10
|
+
# @attr [String] active_to
|
11
11
|
class BlacklistParams
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :entity_type
|
13
13
|
|
14
14
|
|
15
|
-
attr_accessor :
|
15
|
+
attr_accessor :ids
|
16
16
|
|
17
17
|
|
18
|
-
attr_accessor :
|
18
|
+
attr_accessor :disabled
|
19
19
|
|
20
20
|
|
21
|
-
attr_accessor :
|
21
|
+
attr_accessor :scope
|
22
22
|
|
23
23
|
|
24
|
-
attr_accessor :
|
24
|
+
attr_accessor :active_from
|
25
25
|
|
26
26
|
|
27
|
-
attr_accessor :
|
27
|
+
attr_accessor :active_to
|
28
28
|
|
29
29
|
|
30
30
|
def initialize(attributes = {})
|
31
31
|
return if attributes.empty?
|
32
|
-
value = attributes["scope"] || attributes[:"scope"]
|
33
|
-
if value.is_a?(Array)
|
34
|
-
@scope = value
|
35
|
-
|
36
|
-
end
|
37
|
-
# Workaround since JSON.parse has accessors as strings rather than symbols
|
38
|
-
@active_from = attributes["activeFrom"] || attributes[:"active_from"]
|
39
|
-
# Workaround since JSON.parse has accessors as strings rather than symbols
|
40
|
-
@active_to = attributes["activeTo"] || attributes[:"active_to"]
|
41
32
|
# Workaround since JSON.parse has accessors as strings rather than symbols
|
42
33
|
@entity_type = attributes["entityType"] || attributes[:"entity_type"]
|
43
34
|
value = attributes["ids"] || attributes[:"ids"]
|
@@ -47,6 +38,15 @@ module Attune
|
|
47
38
|
end
|
48
39
|
# Workaround since JSON.parse has accessors as strings rather than symbols
|
49
40
|
@disabled = attributes["disabled"] || attributes[:"disabled"]
|
41
|
+
value = attributes["scope"] || attributes[:"scope"]
|
42
|
+
if value.is_a?(Array)
|
43
|
+
@scope = value
|
44
|
+
|
45
|
+
end
|
46
|
+
# Workaround since JSON.parse has accessors as strings rather than symbols
|
47
|
+
@active_from = attributes["activeFrom"] || attributes[:"active_from"]
|
48
|
+
# Workaround since JSON.parse has accessors as strings rather than symbols
|
49
|
+
@active_to = attributes["activeTo"] || attributes[:"active_to"]
|
50
50
|
|
51
51
|
|
52
52
|
end
|
@@ -65,12 +65,12 @@ module Attune
|
|
65
65
|
private
|
66
66
|
# :internal => :external
|
67
67
|
ATTRIBUTE_MAP = {
|
68
|
-
:scope => :scope,
|
69
|
-
:active_from => :activeFrom,
|
70
|
-
:active_to => :activeTo,
|
71
68
|
:entity_type => :entityType,
|
72
69
|
:ids => :ids,
|
73
|
-
:disabled => :disabled
|
70
|
+
:disabled => :disabled,
|
71
|
+
:scope => :scope,
|
72
|
+
:active_from => :activeFrom,
|
73
|
+
:active_to => :activeTo
|
74
74
|
|
75
75
|
}
|
76
76
|
end
|
@@ -2,30 +2,30 @@ module Attune
|
|
2
2
|
module Model
|
3
3
|
# List of ids in ranked order. If an error occurs, returns message and status code.
|
4
4
|
#
|
5
|
-
# @attr [String] message
|
6
|
-
# @attr [
|
7
|
-
# @attr [
|
5
|
+
# @attr [String] message Error message if ranking failed
|
6
|
+
# @attr [Array<String>] ranking List of ids in ranked order
|
7
|
+
# @attr [Integer] status HTTP status code if ranking failed
|
8
8
|
class RankedEntities
|
9
9
|
attr_accessor :message
|
10
10
|
|
11
11
|
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :ranking
|
13
13
|
|
14
14
|
|
15
|
-
attr_accessor :
|
15
|
+
attr_accessor :status
|
16
16
|
|
17
17
|
|
18
18
|
def initialize(attributes = {})
|
19
19
|
return if attributes.empty?
|
20
20
|
# Workaround since JSON.parse has accessors as strings rather than symbols
|
21
21
|
@message = attributes["message"] || attributes[:"message"]
|
22
|
-
# Workaround since JSON.parse has accessors as strings rather than symbols
|
23
|
-
@status = attributes["status"] || attributes[:"status"]
|
24
22
|
value = attributes["ranking"] || attributes[:"ranking"]
|
25
23
|
if value.is_a?(Array)
|
26
24
|
@ranking = value
|
27
25
|
|
28
26
|
end
|
27
|
+
# Workaround since JSON.parse has accessors as strings rather than symbols
|
28
|
+
@status = attributes["status"] || attributes[:"status"]
|
29
29
|
|
30
30
|
|
31
31
|
end
|
@@ -45,8 +45,8 @@ module Attune
|
|
45
45
|
# :internal => :external
|
46
46
|
ATTRIBUTE_MAP = {
|
47
47
|
:message => :message,
|
48
|
-
:
|
49
|
-
:
|
48
|
+
:ranking => :ranking,
|
49
|
+
:status => :status
|
50
50
|
|
51
51
|
}
|
52
52
|
end
|
@@ -2,34 +2,34 @@ module Attune
|
|
2
2
|
module Model
|
3
3
|
# Inputs for ranking a set of ids for a particular user.
|
4
4
|
#
|
5
|
-
# @attr [
|
6
|
-
# @attr [String]
|
7
|
-
# @attr [
|
8
|
-
# @attr [String] user_agent
|
9
|
-
# @attr [String]
|
10
|
-
# @attr [
|
11
|
-
# @attr [String]
|
12
|
-
# @attr [String] view
|
5
|
+
# @attr [String] entity_type
|
6
|
+
# @attr [Array<String>] ids
|
7
|
+
# @attr [Array<Attune::Model::ScopeEntry>] scope
|
8
|
+
# @attr [String] user_agent
|
9
|
+
# @attr [String] anonymous
|
10
|
+
# @attr [String] ip
|
11
|
+
# @attr [String] customer
|
12
|
+
# @attr [String] view
|
13
13
|
class RankingParams
|
14
|
-
attr_accessor :
|
14
|
+
attr_accessor :entity_type
|
15
15
|
|
16
16
|
|
17
|
-
attr_accessor :
|
17
|
+
attr_accessor :ids
|
18
18
|
|
19
19
|
|
20
|
-
attr_accessor :
|
20
|
+
attr_accessor :scope
|
21
21
|
|
22
22
|
|
23
23
|
attr_accessor :user_agent
|
24
24
|
|
25
25
|
|
26
|
-
attr_accessor :
|
26
|
+
attr_accessor :anonymous
|
27
27
|
|
28
28
|
|
29
|
-
attr_accessor :
|
29
|
+
attr_accessor :ip
|
30
30
|
|
31
31
|
|
32
|
-
attr_accessor :
|
32
|
+
attr_accessor :customer
|
33
33
|
|
34
34
|
|
35
35
|
attr_accessor :view
|
@@ -37,27 +37,27 @@ module Attune
|
|
37
37
|
|
38
38
|
def initialize(attributes = {})
|
39
39
|
return if attributes.empty?
|
40
|
+
# Workaround since JSON.parse has accessors as strings rather than symbols
|
41
|
+
@entity_type = attributes["entityType"] || attributes[:"entity_type"]
|
42
|
+
value = attributes["ids"] || attributes[:"ids"]
|
43
|
+
if value.is_a?(Array)
|
44
|
+
@ids = value
|
45
|
+
|
46
|
+
end
|
40
47
|
value = attributes["scope"] || attributes[:"scope"]
|
41
48
|
if value.is_a?(Array)
|
42
49
|
@scope = value.map{ |v| ScopeEntry.new(v) }
|
43
50
|
|
44
51
|
end
|
45
52
|
# Workaround since JSON.parse has accessors as strings rather than symbols
|
46
|
-
@anonymous = attributes["anonymous"] || attributes[:"anonymous"]
|
47
|
-
# Workaround since JSON.parse has accessors as strings rather than symbols
|
48
|
-
@customer = attributes["customer"] || attributes[:"customer"]
|
49
|
-
# Workaround since JSON.parse has accessors as strings rather than symbols
|
50
53
|
@user_agent = attributes["userAgent"] || attributes[:"user_agent"]
|
51
54
|
# Workaround since JSON.parse has accessors as strings rather than symbols
|
52
|
-
@
|
53
|
-
value = attributes["ids"] || attributes[:"ids"]
|
54
|
-
if value.is_a?(Array)
|
55
|
-
@ids = value
|
56
|
-
|
57
|
-
end
|
55
|
+
@anonymous = attributes["anonymous"] || attributes[:"anonymous"]
|
58
56
|
# Workaround since JSON.parse has accessors as strings rather than symbols
|
59
57
|
@ip = attributes["ip"] || attributes[:"ip"]
|
60
58
|
# Workaround since JSON.parse has accessors as strings rather than symbols
|
59
|
+
@customer = attributes["customer"] || attributes[:"customer"]
|
60
|
+
# Workaround since JSON.parse has accessors as strings rather than symbols
|
61
61
|
@view = attributes["view"] || attributes[:"view"]
|
62
62
|
|
63
63
|
|
@@ -77,13 +77,13 @@ module Attune
|
|
77
77
|
private
|
78
78
|
# :internal => :external
|
79
79
|
ATTRIBUTE_MAP = {
|
80
|
-
:scope => :scope,
|
81
|
-
:anonymous => :anonymous,
|
82
|
-
:customer => :customer,
|
83
|
-
:user_agent => :userAgent,
|
84
80
|
:entity_type => :entityType,
|
85
81
|
:ids => :ids,
|
82
|
+
:scope => :scope,
|
83
|
+
:user_agent => :userAgent,
|
84
|
+
:anonymous => :anonymous,
|
86
85
|
:ip => :ip,
|
86
|
+
:customer => :customer,
|
87
87
|
:view => :view
|
88
88
|
|
89
89
|
}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Attune
|
2
2
|
module Model
|
3
|
-
# Name
|
3
|
+
# Name/value pairs that provide additional context to the request
|
4
4
|
#
|
5
|
-
# @attr [String] name
|
6
|
-
# @attr [String] value
|
5
|
+
# @attr [String] name
|
6
|
+
# @attr [String] value
|
7
7
|
class ScopeEntry
|
8
8
|
attr_accessor :name
|
9
9
|
|
data/lib/attune/version.rb
CHANGED
data/spec/remote_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe "remote requests" do
|
|
11
11
|
pending "REMOTE_ENDPOINT required for remote spec" unless endpoint
|
12
12
|
pending "AUTH_TOKEN required for remote spec" unless auth_token
|
13
13
|
end
|
14
|
-
let!(:client){ Attune::Client.new(endpoint: endpoint, auth_token: auth_token
|
14
|
+
let!(:client){ Attune::Client.new(endpoint: endpoint, auth_token: auth_token) }
|
15
15
|
|
16
16
|
it "can request an auth_token given a client id and secret" do
|
17
17
|
pending "CLIENT_ID required for get_auth_token spec" unless client_id
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attune
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Hawthorn
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- lib/attune/client.rb
|
148
148
|
- lib/attune/configurable.rb
|
149
149
|
- lib/attune/default.rb
|
150
|
+
- lib/attune/gzip_request.rb
|
150
151
|
- lib/attune/json_logger.rb
|
151
152
|
- lib/attune/mocks.rb
|
152
153
|
- lib/attune/models/anonymous_result.rb
|