yotpo_api_smart_map 1.0.0
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 +7 -0
- data/README.md +89 -0
- data/docs/SmartMapsApi.md +53 -0
- data/docs/SmartmapAccountStats.md +8 -0
- data/docs/SmartmapArgs.md +8 -0
- data/docs/SmartmapExcludedDay.md +9 -0
- data/git_push.sh +52 -0
- data/lib/yotpo_api_smart_map.rb +41 -0
- data/lib/yotpo_api_smart_map/api/smart_maps_api.rb +81 -0
- data/lib/yotpo_api_smart_map/api_client.rb +330 -0
- data/lib/yotpo_api_smart_map/api_error.rb +34 -0
- data/lib/yotpo_api_smart_map/configuration.rb +163 -0
- data/lib/yotpo_api_smart_map/models/smartmap_account_stats.rb +161 -0
- data/lib/yotpo_api_smart_map/models/smartmap_args.rb +159 -0
- data/lib/yotpo_api_smart_map/models/smartmap_excluded_day.rb +169 -0
- data/lib/yotpo_api_smart_map/version.rb +13 -0
- data/spec/api/smart_maps_api_spec.rb +49 -0
- data/spec/models/smartmap_account_stats_spec.rb +44 -0
- data/spec/models/smartmap_args_spec.rb +44 -0
- data/spec/models/smartmap_excluded_day_spec.rb +54 -0
- data/yotpo_api_smart_map.gemspec +32 -0
- metadata +248 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
=begin
|
2
|
+
smartmap.proto
|
3
|
+
|
4
|
+
OpenAPI spec version: version not set
|
5
|
+
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
|
9
|
+
=end
|
10
|
+
|
11
|
+
module YotpoApiSmartMap
|
12
|
+
class ApiError < StandardError
|
13
|
+
attr_reader :code, :response_headers, :response_body
|
14
|
+
|
15
|
+
# Usage examples:
|
16
|
+
# ApiError.new
|
17
|
+
# ApiError.new("message")
|
18
|
+
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
19
|
+
# ApiError.new(:code => 404, :message => "Not Found")
|
20
|
+
def initialize(arg = nil)
|
21
|
+
if arg.is_a? Hash
|
22
|
+
arg.each do |k, v|
|
23
|
+
if k.to_s == 'message'
|
24
|
+
super v
|
25
|
+
else
|
26
|
+
instance_variable_set "@#{k}", v
|
27
|
+
end
|
28
|
+
end
|
29
|
+
else
|
30
|
+
super arg
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module YotpoApiSmartMap
|
4
|
+
class Configuration
|
5
|
+
# Defines url scheme
|
6
|
+
attr_accessor :scheme
|
7
|
+
|
8
|
+
# Defines url host
|
9
|
+
attr_accessor :host
|
10
|
+
|
11
|
+
# Defines url base path
|
12
|
+
attr_accessor :base_path
|
13
|
+
|
14
|
+
# Defines API keys used with API Key authentications.
|
15
|
+
#
|
16
|
+
# @return [Hash] key: parameter name, value: parameter value (API key)
|
17
|
+
#
|
18
|
+
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
19
|
+
# config.api_key['api_key'] = 'xxx'
|
20
|
+
attr_accessor :api_key
|
21
|
+
|
22
|
+
# Defines API key prefixes used with API Key authentications.
|
23
|
+
#
|
24
|
+
# @return [Hash] key: parameter name, value: API key prefix
|
25
|
+
#
|
26
|
+
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
27
|
+
# config.api_key_prefix['api_key'] = 'Token'
|
28
|
+
attr_accessor :api_key_prefix
|
29
|
+
|
30
|
+
# Defines the username used with HTTP basic authentication.
|
31
|
+
#
|
32
|
+
# @return [String]
|
33
|
+
attr_accessor :username
|
34
|
+
|
35
|
+
# Defines the password used with HTTP basic authentication.
|
36
|
+
#
|
37
|
+
# @return [String]
|
38
|
+
attr_accessor :password
|
39
|
+
|
40
|
+
# Defines the access token (Bearer) used with OAuth2.
|
41
|
+
attr_accessor :access_token
|
42
|
+
|
43
|
+
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
44
|
+
# details will be logged with `logger.debug` (see the `logger` attribute).
|
45
|
+
# Default to false.
|
46
|
+
#
|
47
|
+
# @return [true, false]
|
48
|
+
attr_accessor :debugging
|
49
|
+
|
50
|
+
# Defines the logger used for debugging.
|
51
|
+
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
52
|
+
#
|
53
|
+
# @return [#debug]
|
54
|
+
attr_accessor :logger
|
55
|
+
|
56
|
+
# Defines the temporary folder to store downloaded files
|
57
|
+
# (for API endpoints that have file response).
|
58
|
+
# Default to use `Tempfile`.
|
59
|
+
#
|
60
|
+
# @return [String]
|
61
|
+
attr_accessor :temp_folder_path
|
62
|
+
|
63
|
+
# The time limit for HTTP request in seconds.
|
64
|
+
# Default to 0 (never times out).
|
65
|
+
attr_accessor :timeout
|
66
|
+
|
67
|
+
### TLS/SSL
|
68
|
+
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
69
|
+
# Default to true.
|
70
|
+
#
|
71
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
72
|
+
#
|
73
|
+
# @return [true, false]
|
74
|
+
attr_accessor :verify_ssl
|
75
|
+
|
76
|
+
# Set this to customize the certificate file to verify the peer.
|
77
|
+
#
|
78
|
+
# @return [String] the path to the certificate file
|
79
|
+
#
|
80
|
+
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
|
81
|
+
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
82
|
+
attr_accessor :ssl_ca_cert
|
83
|
+
|
84
|
+
# Client certificate file (for client certificate)
|
85
|
+
attr_accessor :cert_file
|
86
|
+
|
87
|
+
# Client private key file (for client certificate)
|
88
|
+
attr_accessor :key_file
|
89
|
+
|
90
|
+
attr_accessor :inject_format
|
91
|
+
|
92
|
+
attr_accessor :force_ending_format
|
93
|
+
|
94
|
+
def initialize
|
95
|
+
@scheme = 'http'
|
96
|
+
@host = ''
|
97
|
+
@base_path = ''
|
98
|
+
@api_key = {}
|
99
|
+
@api_key_prefix = {}
|
100
|
+
@timeout = 0
|
101
|
+
@verify_ssl = true
|
102
|
+
@cert_file = nil
|
103
|
+
@key_file = nil
|
104
|
+
@debugging = false
|
105
|
+
@inject_format = false
|
106
|
+
@force_ending_format = false
|
107
|
+
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
108
|
+
|
109
|
+
yield(self) if block_given?
|
110
|
+
end
|
111
|
+
|
112
|
+
# The default Configuration object.
|
113
|
+
def self.default
|
114
|
+
@@default ||= Configuration.new
|
115
|
+
end
|
116
|
+
|
117
|
+
def configure
|
118
|
+
yield(self) if block_given?
|
119
|
+
end
|
120
|
+
|
121
|
+
def scheme=(scheme)
|
122
|
+
# remove :// from scheme
|
123
|
+
@scheme = scheme.sub(/:\/\//, '')
|
124
|
+
end
|
125
|
+
|
126
|
+
def host=(host)
|
127
|
+
# remove http(s):// and anything after a slash
|
128
|
+
@host = host.sub(/https?:\/\//, '').split('/').first
|
129
|
+
end
|
130
|
+
|
131
|
+
def base_path=(base_path)
|
132
|
+
# Add leading and trailing slashes to base_path
|
133
|
+
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
134
|
+
@base_path = "" if @base_path == "/"
|
135
|
+
end
|
136
|
+
|
137
|
+
def base_url
|
138
|
+
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
139
|
+
URI.encode(url)
|
140
|
+
end
|
141
|
+
|
142
|
+
# Gets API key (with prefix if set).
|
143
|
+
# @param [String] param_name the parameter name of API key auth
|
144
|
+
def api_key_with_prefix(param_name)
|
145
|
+
if @api_key_prefix[param_name]
|
146
|
+
"#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
|
147
|
+
else
|
148
|
+
@api_key[param_name]
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Gets Basic Auth token string
|
153
|
+
def basic_auth_token
|
154
|
+
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
155
|
+
end
|
156
|
+
|
157
|
+
# Returns Auth Settings hash for api client.
|
158
|
+
def auth_settings
|
159
|
+
{
|
160
|
+
}
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
=begin
|
2
|
+
smartmap.proto
|
3
|
+
|
4
|
+
OpenAPI spec version: version not set
|
5
|
+
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
|
9
|
+
=end
|
10
|
+
|
11
|
+
require 'date'
|
12
|
+
|
13
|
+
module YotpoApiSmartMap
|
14
|
+
class SmartmapAccountStats
|
15
|
+
attr_accessor :excluded_days
|
16
|
+
|
17
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
18
|
+
def self.attribute_map
|
19
|
+
{
|
20
|
+
|
21
|
+
:'excluded_days' => :'excludedDays'
|
22
|
+
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Attribute type mapping.
|
27
|
+
def self.swagger_types
|
28
|
+
{
|
29
|
+
:'excluded_days' => :'Array<SmartmapExcludedDay>'
|
30
|
+
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize(attributes = {})
|
35
|
+
return unless attributes.is_a?(Hash)
|
36
|
+
|
37
|
+
# convert string to symbol for hash key
|
38
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
39
|
+
|
40
|
+
|
41
|
+
if attributes[:'excludedDays']
|
42
|
+
if (value = attributes[:'excludedDays']).is_a?(Array)
|
43
|
+
self.excluded_days = value
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
# Check equality by comparing each attribute.
|
50
|
+
def ==(o)
|
51
|
+
return true if self.equal?(o)
|
52
|
+
self.class == o.class &&
|
53
|
+
excluded_days == o.excluded_days
|
54
|
+
end
|
55
|
+
|
56
|
+
# @see the `==` method
|
57
|
+
def eql?(o)
|
58
|
+
self == o
|
59
|
+
end
|
60
|
+
|
61
|
+
# Calculate hash code according to all attributes.
|
62
|
+
def hash
|
63
|
+
[excluded_days].hash
|
64
|
+
end
|
65
|
+
|
66
|
+
# build the object from hash
|
67
|
+
def build_from_hash(attributes)
|
68
|
+
return nil unless attributes.is_a?(Hash)
|
69
|
+
self.class.swagger_types.each_pair do |key, type|
|
70
|
+
if type =~ /^Array<(.*)>/i
|
71
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
72
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
73
|
+
else
|
74
|
+
#TODO show warning in debug mode
|
75
|
+
end
|
76
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
77
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
78
|
+
else
|
79
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
self
|
84
|
+
end
|
85
|
+
|
86
|
+
def _deserialize(type, value)
|
87
|
+
case type.to_sym
|
88
|
+
when :DateTime
|
89
|
+
DateTime.parse(value)
|
90
|
+
when :Date
|
91
|
+
Date.parse(value)
|
92
|
+
when :String
|
93
|
+
value.to_s
|
94
|
+
when :Integer
|
95
|
+
value.to_i
|
96
|
+
when :Float
|
97
|
+
value.to_f
|
98
|
+
when :BOOLEAN
|
99
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
100
|
+
true
|
101
|
+
else
|
102
|
+
false
|
103
|
+
end
|
104
|
+
when :Object
|
105
|
+
# generic object (usually a Hash), return directly
|
106
|
+
value
|
107
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
108
|
+
inner_type = Regexp.last_match[:inner_type]
|
109
|
+
value.map { |v| _deserialize(inner_type, v) }
|
110
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
111
|
+
k_type = Regexp.last_match[:k_type]
|
112
|
+
v_type = Regexp.last_match[:v_type]
|
113
|
+
{}.tap do |hash|
|
114
|
+
value.each do |k, v|
|
115
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
else # model
|
119
|
+
_model = YotpoApiSmartMap.const_get(type).new
|
120
|
+
_model.build_from_hash(value)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def to_s
|
125
|
+
to_hash.to_s
|
126
|
+
end
|
127
|
+
|
128
|
+
# to_body is an alias to to_body (backward compatibility))
|
129
|
+
def to_body
|
130
|
+
to_hash
|
131
|
+
end
|
132
|
+
|
133
|
+
# return the object in the form of hash
|
134
|
+
def to_hash
|
135
|
+
hash = {}
|
136
|
+
self.class.attribute_map.each_pair do |attr, param|
|
137
|
+
value = self.send(attr)
|
138
|
+
next if value.nil?
|
139
|
+
hash[param] = _to_hash(value)
|
140
|
+
end
|
141
|
+
hash
|
142
|
+
end
|
143
|
+
|
144
|
+
# Method to output non-array value in the form of hash
|
145
|
+
# For object, use to_hash. Otherwise, just return the value
|
146
|
+
def _to_hash(value)
|
147
|
+
if value.is_a?(Array)
|
148
|
+
value.compact.map{ |v| _to_hash(v) }
|
149
|
+
elsif value.is_a?(Hash)
|
150
|
+
{}.tap do |hash|
|
151
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
152
|
+
end
|
153
|
+
elsif value.respond_to? :to_hash
|
154
|
+
value.to_hash
|
155
|
+
else
|
156
|
+
value
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
=begin
|
2
|
+
smartmap.proto
|
3
|
+
|
4
|
+
OpenAPI spec version: version not set
|
5
|
+
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
|
9
|
+
=end
|
10
|
+
|
11
|
+
require 'date'
|
12
|
+
|
13
|
+
module YotpoApiSmartMap
|
14
|
+
class SmartmapArgs
|
15
|
+
attr_accessor :account_id
|
16
|
+
|
17
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
18
|
+
def self.attribute_map
|
19
|
+
{
|
20
|
+
|
21
|
+
:'account_id' => :'accountId'
|
22
|
+
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Attribute type mapping.
|
27
|
+
def self.swagger_types
|
28
|
+
{
|
29
|
+
:'account_id' => :'String'
|
30
|
+
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize(attributes = {})
|
35
|
+
return unless attributes.is_a?(Hash)
|
36
|
+
|
37
|
+
# convert string to symbol for hash key
|
38
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
39
|
+
|
40
|
+
|
41
|
+
if attributes[:'accountId']
|
42
|
+
self.account_id = attributes[:'accountId']
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
# Check equality by comparing each attribute.
|
48
|
+
def ==(o)
|
49
|
+
return true if self.equal?(o)
|
50
|
+
self.class == o.class &&
|
51
|
+
account_id == o.account_id
|
52
|
+
end
|
53
|
+
|
54
|
+
# @see the `==` method
|
55
|
+
def eql?(o)
|
56
|
+
self == o
|
57
|
+
end
|
58
|
+
|
59
|
+
# Calculate hash code according to all attributes.
|
60
|
+
def hash
|
61
|
+
[account_id].hash
|
62
|
+
end
|
63
|
+
|
64
|
+
# build the object from hash
|
65
|
+
def build_from_hash(attributes)
|
66
|
+
return nil unless attributes.is_a?(Hash)
|
67
|
+
self.class.swagger_types.each_pair do |key, type|
|
68
|
+
if type =~ /^Array<(.*)>/i
|
69
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
70
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
71
|
+
else
|
72
|
+
#TODO show warning in debug mode
|
73
|
+
end
|
74
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
75
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
76
|
+
else
|
77
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
self
|
82
|
+
end
|
83
|
+
|
84
|
+
def _deserialize(type, value)
|
85
|
+
case type.to_sym
|
86
|
+
when :DateTime
|
87
|
+
DateTime.parse(value)
|
88
|
+
when :Date
|
89
|
+
Date.parse(value)
|
90
|
+
when :String
|
91
|
+
value.to_s
|
92
|
+
when :Integer
|
93
|
+
value.to_i
|
94
|
+
when :Float
|
95
|
+
value.to_f
|
96
|
+
when :BOOLEAN
|
97
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
98
|
+
true
|
99
|
+
else
|
100
|
+
false
|
101
|
+
end
|
102
|
+
when :Object
|
103
|
+
# generic object (usually a Hash), return directly
|
104
|
+
value
|
105
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
106
|
+
inner_type = Regexp.last_match[:inner_type]
|
107
|
+
value.map { |v| _deserialize(inner_type, v) }
|
108
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
109
|
+
k_type = Regexp.last_match[:k_type]
|
110
|
+
v_type = Regexp.last_match[:v_type]
|
111
|
+
{}.tap do |hash|
|
112
|
+
value.each do |k, v|
|
113
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
else # model
|
117
|
+
_model = YotpoApiSmartMap.const_get(type).new
|
118
|
+
_model.build_from_hash(value)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def to_s
|
123
|
+
to_hash.to_s
|
124
|
+
end
|
125
|
+
|
126
|
+
# to_body is an alias to to_body (backward compatibility))
|
127
|
+
def to_body
|
128
|
+
to_hash
|
129
|
+
end
|
130
|
+
|
131
|
+
# return the object in the form of hash
|
132
|
+
def to_hash
|
133
|
+
hash = {}
|
134
|
+
self.class.attribute_map.each_pair do |attr, param|
|
135
|
+
value = self.send(attr)
|
136
|
+
next if value.nil?
|
137
|
+
hash[param] = _to_hash(value)
|
138
|
+
end
|
139
|
+
hash
|
140
|
+
end
|
141
|
+
|
142
|
+
# Method to output non-array value in the form of hash
|
143
|
+
# For object, use to_hash. Otherwise, just return the value
|
144
|
+
def _to_hash(value)
|
145
|
+
if value.is_a?(Array)
|
146
|
+
value.compact.map{ |v| _to_hash(v) }
|
147
|
+
elsif value.is_a?(Hash)
|
148
|
+
{}.tap do |hash|
|
149
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
150
|
+
end
|
151
|
+
elsif value.respond_to? :to_hash
|
152
|
+
value.to_hash
|
153
|
+
else
|
154
|
+
value
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|