attune 1.0.5 → 1.0.6

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,11 @@
1
+ module Attune
2
+ MOCKS = {
3
+ 'Anonymous.create' => Proc.new{ {:id => SecureRandom.uuid } },
4
+ 'Entities.get_rankings' => Proc.new{ |body| { :ranking => body.ids.map(&:to_s) } },
5
+ 'Entities.batch_get_rankings' => Proc.new{ |body|
6
+ { :results => body.requests.map {
7
+ |params| { :ranking => params.ids.map(&:to_s) }
8
+ } }
9
+ }
10
+ }
11
+ end
@@ -0,0 +1,38 @@
1
+ module Attune
2
+ module Model
3
+ # Result of creating an anonymous user.
4
+ #
5
+ # @attr [String] id
6
+ class AnonymousResult
7
+ attr_accessor :id
8
+
9
+
10
+ def initialize(attributes = {})
11
+ return if attributes.empty?
12
+ # Workaround since JSON.parse has accessors as strings rather than symbols
13
+ @id = attributes["id"] || attributes[:"id"]
14
+
15
+
16
+ end
17
+
18
+ def to_body
19
+ Hash[ATTRIBUTE_MAP.map do |internal, external|
20
+ next unless value = send(internal)
21
+ [external, value]
22
+ end.compact]
23
+ end
24
+
25
+ def to_json(options = {})
26
+ to_body.to_json
27
+ end
28
+
29
+ private
30
+ # :internal => :external
31
+ ATTRIBUTE_MAP = {
32
+ :id => :id
33
+
34
+ }
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,41 @@
1
+ module Attune
2
+ module Model
3
+ # Wrapper for requesting multiple rankings in a single call.
4
+ #
5
+ # @attr [Array<Attune::Model::RankingParams>] requests
6
+ class BatchRankingRequest
7
+ attr_accessor :requests
8
+
9
+
10
+ def initialize(attributes = {})
11
+ return if attributes.empty?
12
+ value = attributes["requests"] || attributes[:"requests"]
13
+ if value.is_a?(Array)
14
+ @requests = value.map{ |v| RankingParams.new(v) }
15
+
16
+ end
17
+
18
+
19
+ end
20
+
21
+ def to_body
22
+ Hash[ATTRIBUTE_MAP.map do |internal, external|
23
+ next unless value = send(internal)
24
+ [external, value]
25
+ end.compact]
26
+ end
27
+
28
+ def to_json(options = {})
29
+ to_body.to_json
30
+ end
31
+
32
+ private
33
+ # :internal => :external
34
+ ATTRIBUTE_MAP = {
35
+ :requests => :requests
36
+
37
+ }
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,41 @@
1
+ module Attune
2
+ module Model
3
+ # Wrapper of multiple ranking results.
4
+ #
5
+ # @attr [Array<Attune::Model::RankedEntities>] results
6
+ class BatchRankingResult
7
+ attr_accessor :results
8
+
9
+
10
+ def initialize(attributes = {})
11
+ return if attributes.empty?
12
+ value = attributes["results"] || attributes[:"results"]
13
+ if value.is_a?(Array)
14
+ @results = value.map{ |v| RankedEntities.new(v) }
15
+
16
+ end
17
+
18
+
19
+ end
20
+
21
+ def to_body
22
+ Hash[ATTRIBUTE_MAP.map do |internal, external|
23
+ next unless value = send(internal)
24
+ [external, value]
25
+ end.compact]
26
+ end
27
+
28
+ def to_json(options = {})
29
+ to_body.to_json
30
+ end
31
+
32
+ private
33
+ # :internal => :external
34
+ ATTRIBUTE_MAP = {
35
+ :results => :results
36
+
37
+ }
38
+ end
39
+ end
40
+ end
41
+
@@ -1,6 +1,16 @@
1
1
  module Attune
2
2
  module Model
3
3
  #
4
+ #
5
+ # @attr [String] id
6
+ # @attr [Array<String>] ids
7
+ # @attr [Boolean] disabled
8
+ # @attr [Array<String>] scope
9
+ # @attr [String] consumer
10
+ # @attr [String] entity_type
11
+ # @attr [String] start_date
12
+ # @attr [String] end_date
13
+ # @attr [String] created_at
4
14
  class Blacklist
5
15
  attr_accessor :id
6
16
 
@@ -8,103 +18,82 @@ module Attune
8
18
  attr_accessor :ids
9
19
 
10
20
 
11
- attr_accessor :entity_type
21
+ attr_accessor :disabled
12
22
 
13
23
 
14
- attr_accessor :consumer
24
+ attr_accessor :scope
15
25
 
16
26
 
17
- attr_accessor :created_at
27
+ attr_accessor :consumer
18
28
 
19
29
 
20
- attr_accessor :end_date
30
+ attr_accessor :entity_type
21
31
 
22
32
 
23
33
  attr_accessor :start_date
24
34
 
25
35
 
26
- attr_accessor :disabled
36
+ attr_accessor :end_date
27
37
 
28
38
 
29
- attr_accessor :scope
39
+ attr_accessor :created_at
30
40
 
31
41
 
32
- # :internal => :external
33
- def self.attribute_map
34
- {
35
- :id => :id,
36
- :ids => :ids,
37
- :entity_type => :entityType,
38
- :consumer => :consumer,
39
- :created_at => :createdAt,
40
- :end_date => :endDate,
41
- :start_date => :startDate,
42
- :disabled => :disabled,
43
- :scope => :scope
44
-
45
- }
46
- end
47
-
48
42
  def initialize(attributes = {})
49
43
  return if attributes.empty?
50
- # Morph attribute keys into undescored rubyish style
51
- if self.class.attribute_map[:"id"]
52
- # Workaround since JSON.parse has accessors as strings rather than symbols
53
- @id = attributes["id"] || attributes[:"id"]
54
- end
55
- if self.class.attribute_map[:"ids"]
56
- value = attributes["ids"] || attributes[:"ids"]
57
- if value.is_a?(Array)
58
- @ids = value
59
-
60
- end
61
- end
62
- if self.class.attribute_map[:"entity_type"]
63
- # Workaround since JSON.parse has accessors as strings rather than symbols
64
- @entity_type = attributes["entityType"] || attributes[:"entity_type"]
65
- end
66
- if self.class.attribute_map[:"consumer"]
67
- # Workaround since JSON.parse has accessors as strings rather than symbols
68
- @consumer = attributes["consumer"] || attributes[:"consumer"]
69
- end
70
- if self.class.attribute_map[:"created_at"]
71
- # Workaround since JSON.parse has accessors as strings rather than symbols
72
- @created_at = attributes["createdAt"] || attributes[:"created_at"]
73
- end
74
- if self.class.attribute_map[:"end_date"]
75
- # Workaround since JSON.parse has accessors as strings rather than symbols
76
- @end_date = attributes["endDate"] || attributes[:"end_date"]
77
- end
78
- if self.class.attribute_map[:"start_date"]
79
- # Workaround since JSON.parse has accessors as strings rather than symbols
80
- @start_date = attributes["startDate"] || attributes[:"start_date"]
81
- end
82
- if self.class.attribute_map[:"disabled"]
83
- # Workaround since JSON.parse has accessors as strings rather than symbols
84
- @disabled = attributes["disabled"] || attributes[:"disabled"]
44
+ # Workaround since JSON.parse has accessors as strings rather than symbols
45
+ @id = attributes["id"] || attributes[:"id"]
46
+ value = attributes["ids"] || attributes[:"ids"]
47
+ if value.is_a?(Array)
48
+ @ids = value
49
+
85
50
  end
86
- if self.class.attribute_map[:"scope"]
87
- value = attributes["scope"] || attributes[:"scope"]
88
- if value.is_a?(Array)
89
- @scope = value
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
90
56
 
91
- end
92
- end
57
+ end
58
+ # Workaround since JSON.parse has accessors as strings rather than symbols
59
+ @consumer = attributes["consumer"] || attributes[:"consumer"]
60
+ # Workaround since JSON.parse has accessors as strings rather than symbols
61
+ @entity_type = attributes["entityType"] || attributes[:"entity_type"]
62
+ # Workaround since JSON.parse has accessors as strings rather than symbols
63
+ @start_date = attributes["startDate"] || attributes[:"start_date"]
64
+ # Workaround since JSON.parse has accessors as strings rather than symbols
65
+ @end_date = attributes["endDate"] || attributes[:"end_date"]
66
+ # Workaround since JSON.parse has accessors as strings rather than symbols
67
+ @created_at = attributes["createdAt"] || attributes[:"created_at"]
93
68
 
94
69
 
95
70
  end
96
71
 
97
72
  def to_body
98
- body = {}
99
- self.class.attribute_map.each_pair do |key, value|
100
- body[value] = self.send(key) unless self.send(key).nil?
101
- end
102
- body
73
+ Hash[ATTRIBUTE_MAP.map do |internal, external|
74
+ next unless value = send(internal)
75
+ [external, value]
76
+ end.compact]
103
77
  end
104
78
 
105
79
  def to_json(options = {})
106
80
  to_body.to_json
107
81
  end
82
+
83
+ private
84
+ # :internal => :external
85
+ ATTRIBUTE_MAP = {
86
+ :id => :id,
87
+ :ids => :ids,
88
+ :disabled => :disabled,
89
+ :scope => :scope,
90
+ :consumer => :consumer,
91
+ :entity_type => :entityType,
92
+ :start_date => :startDate,
93
+ :end_date => :endDate,
94
+ :created_at => :createdAt
95
+
96
+ }
108
97
  end
109
98
  end
110
99
  end
@@ -0,0 +1,41 @@
1
+ module Attune
2
+ module Model
3
+ #
4
+ #
5
+ # @attr [Array<Attune::Model::Blacklist>] blacklists
6
+ class BlacklistGetResponse
7
+ attr_accessor :blacklists
8
+
9
+
10
+ def initialize(attributes = {})
11
+ return if attributes.empty?
12
+ value = attributes["blacklists"] || attributes[:"blacklists"]
13
+ if value.is_a?(Array)
14
+ @blacklists = value.map{ |v| Blacklist.new(v) }
15
+
16
+ end
17
+
18
+
19
+ end
20
+
21
+ def to_body
22
+ Hash[ATTRIBUTE_MAP.map do |internal, external|
23
+ next unless value = send(internal)
24
+ [external, value]
25
+ end.compact]
26
+ end
27
+
28
+ def to_json(options = {})
29
+ to_body.to_json
30
+ end
31
+
32
+ private
33
+ # :internal => :external
34
+ ATTRIBUTE_MAP = {
35
+ :blacklists => :blacklists
36
+
37
+ }
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,79 @@
1
+ module Attune
2
+ module Model
3
+ #
4
+ #
5
+ # @attr [Array<String>] scope
6
+ # @attr [String] active_from
7
+ # @attr [String] active_to
8
+ # @attr [String] entity_type
9
+ # @attr [Array<String>] ids
10
+ # @attr [Boolean] disabled
11
+ class BlacklistParams
12
+ attr_accessor :scope
13
+
14
+
15
+ attr_accessor :active_from
16
+
17
+
18
+ attr_accessor :active_to
19
+
20
+
21
+ attr_accessor :entity_type
22
+
23
+
24
+ attr_accessor :ids
25
+
26
+
27
+ attr_accessor :disabled
28
+
29
+
30
+ def initialize(attributes = {})
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
+ # Workaround since JSON.parse has accessors as strings rather than symbols
42
+ @entity_type = attributes["entityType"] || attributes[:"entity_type"]
43
+ value = attributes["ids"] || attributes[:"ids"]
44
+ if value.is_a?(Array)
45
+ @ids = value
46
+
47
+ end
48
+ # Workaround since JSON.parse has accessors as strings rather than symbols
49
+ @disabled = attributes["disabled"] || attributes[:"disabled"]
50
+
51
+
52
+ end
53
+
54
+ def to_body
55
+ Hash[ATTRIBUTE_MAP.map do |internal, external|
56
+ next unless value = send(internal)
57
+ [external, value]
58
+ end.compact]
59
+ end
60
+
61
+ def to_json(options = {})
62
+ to_body.to_json
63
+ end
64
+
65
+ private
66
+ # :internal => :external
67
+ ATTRIBUTE_MAP = {
68
+ :scope => :scope,
69
+ :active_from => :activeFrom,
70
+ :active_to => :activeTo,
71
+ :entity_type => :entityType,
72
+ :ids => :ids,
73
+ :disabled => :disabled
74
+
75
+ }
76
+ end
77
+ end
78
+ end
79
+
@@ -0,0 +1,38 @@
1
+ module Attune
2
+ module Model
3
+ #
4
+ #
5
+ # @attr [String] result
6
+ class BlacklistSaveResponse
7
+ attr_accessor :result
8
+
9
+
10
+ def initialize(attributes = {})
11
+ return if attributes.empty?
12
+ # Workaround since JSON.parse has accessors as strings rather than symbols
13
+ @result = attributes["result"] || attributes[:"result"]
14
+
15
+
16
+ end
17
+
18
+ def to_body
19
+ Hash[ATTRIBUTE_MAP.map do |internal, external|
20
+ next unless value = send(internal)
21
+ [external, value]
22
+ end.compact]
23
+ end
24
+
25
+ def to_json(options = {})
26
+ to_body.to_json
27
+ end
28
+
29
+ private
30
+ # :internal => :external
31
+ ATTRIBUTE_MAP = {
32
+ :result => :result
33
+
34
+ }
35
+ end
36
+ end
37
+ end
38
+