mastercard_core_sdk 1.1.3 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e7df2eff37964c63a22e1236da3947f19a991b4
4
- data.tar.gz: 76953aebb3f13d721632da658b251fdb04c678f5
3
+ metadata.gz: eb6b59bd4a75a56d7b91cae232074730af2f6c7c
4
+ data.tar.gz: 6c91654b4b2a27b6cc02b9c9a40717976b4d1226
5
5
  SHA512:
6
- metadata.gz: 098ae2e010fd9bd98a8711a9303fa69c3bf113fc10abe0be31976dd8bdd43c1de2d1ab1c4286b8680c13dc3b078fbd7f8d3ce3dc91e4aa92c1e9bde454f237ca
7
- data.tar.gz: e756bba10eba20b7ef1c639fb9230ec42a6abce1c6c082f0be4e70a89f53a9e68dccac1e33b533c44ed2226e6f6186d4c5da9c2da8d70fdcae1826c359409b81
6
+ metadata.gz: dc1476806427da0fb09cd120393b035509f819f21a496f9241fcf6ba67e5791a73f45d34b8bde6d3de043faacc4293128db41d2764aff4e4087fc641785206ca
7
+ data.tar.gz: 8d51ea7648a7eb4f98d037c300293a1922b8d193744e5ae1f12eb8555245fa40933c18c31efa098f03096c8d1e0f732e70b34f6222ac8811cc614a4a6af1c017
@@ -9,11 +9,11 @@ module MastercardCoreSdk
9
9
  include MastercardCoreSdk::Core, MastercardCoreSdk::Client, MastercardCoreSdk::Exceptions, MastercardCoreSdk::Tracker
10
10
 
11
11
  # Access Token Api service
12
- # @param oauth_verifier
13
12
  # @param oauth_token
13
+ # @param oauth_verifier
14
14
  # @param api_config Optional ApiConfig object.
15
15
  # @return [AccessTokenResponse]
16
- def self.create(oauth_verifier, oauth_token, api_config = nil)
16
+ def self.create(oauth_token, oauth_verifier, api_config = nil)
17
17
  path = "/oauth/consumer/v1/access_token"
18
18
 
19
19
  service_request = ServiceRequest.new
@@ -89,7 +89,7 @@ module MastercardCoreSdk
89
89
  end
90
90
 
91
91
  if return_type
92
- converter = SDKConverterFactory.get_converter(mime_sub_type(response.headers['Content-Type']))
92
+ converter = SDKConverterFactory.get_converter(response.headers['Content-Type'])
93
93
  data = converter.response_body_converter(response.response_body, return_type)
94
94
  else
95
95
  data = nil
@@ -101,8 +101,8 @@ module MastercardCoreSdk
101
101
  def build_request(http_method, path, request, api_config)
102
102
  url = build_request_url(path, request, api_config)
103
103
  http_method = http_method.to_sym.downcase
104
- content_type_header = {"Content-Type" => request.content_type}
105
- api_config_header = {ApiConfig::CONFIG_NAME_HEADER => @api_config.name}
104
+ content_type_header = { "Content-Type" => request.content_type }
105
+ api_config_header = { ApiConfig::CONFIG_NAME_HEADER => @api_config.name }
106
106
  header_params = @default_headers.merge(content_type_header || {}).merge(request.headers || {}).merge(api_config_header)
107
107
  query_params = request.query_params || {}
108
108
 
@@ -138,8 +138,8 @@ module MastercardCoreSdk
138
138
  body = service_request.body || nil
139
139
  data = nil
140
140
  if body
141
- converter = SDKConverterFactory.get_converter(mime_sub_type(content_type))
142
- data = converter.request_body_converter(body)
141
+ converter = SDKConverterFactory.get_converter(content_type)
142
+ data = converter.request_body_converter(body)
143
143
  end
144
144
  return data
145
145
  end
@@ -148,44 +148,6 @@ module MastercardCoreSdk
148
148
  @user_agent = user_agent
149
149
  @default_headers['User-Agent'] = @user_agent
150
150
  end
151
-
152
-
153
- def mime_sub_type(content_type)
154
- mime_type = ""
155
- if json_mime?(content_type)
156
- mime_type = JSON_MIME_TYPE
157
- elsif xml_mime?(content_type)
158
- mime_type = XML_MIME_TYPE
159
- elsif urlencoded_mime?(content_type)
160
- mime_type = URLENCODED_MIME_TYPE
161
- end
162
- return mime_type
163
- end
164
-
165
- # Check if the given MIME is a JSON MIME.
166
- # JSON MIME examples:
167
- # application/json
168
- # application/json; charset=UTF8
169
- # APPLICATION/JSON
170
- def json_mime?(mime)
171
- !!(mime =~ /\Aapplication\/json(;.*)?\z/i)
172
- end
173
-
174
- # Check if the given MIME is a XML MIME.
175
- # XML MIME examples:
176
- # application/xml
177
- # application/xml; charset=UTF8
178
- # APPLICATION/XML
179
- def xml_mime?(mime)
180
- !!(mime =~ /\Aapplication\/xml(;.*)?\z/i)
181
- end
182
-
183
- # Check if the given MIME is a X-WWW-FORM_URLENCODED MIME.
184
- # XML MIME examples:
185
- # application/x-www-form-urlencoded
186
- def urlencoded_mime?(mime)
187
- !!(mime =~ /\Aapplication\/x-www-form-urlencoded(;.*)?\z/i)
188
- end
189
151
 
190
152
  end
191
153
  end
@@ -48,7 +48,6 @@ module MastercardCoreSdk
48
48
  MESSAGE = "Message"
49
49
  HTTP_CODE = "HttpCode"
50
50
 
51
- SSL_CA_CER_PATH_LOCATION = '/data/cert.pem'
52
51
  BASE_SDK_VERSION = "base_sdk_version="
53
52
  CLIENT_SDK_VERSION = "client_sdk_version="
54
53
  LANG_NAME = "lang_name="
@@ -64,7 +63,7 @@ module MastercardCoreSdk
64
63
  HYPHEN = " - "
65
64
 
66
65
  LOG_RESPONSE = "Response: "
67
- LOG_RESPONSE_INFORMATION= "Response Information"
66
+ LOG_RESPONSE_INFORMATION = "Response Information"
68
67
  LOG_URI = "Uri: "
69
68
  LOG_CONTENT = "Content: "
70
69
 
@@ -75,11 +74,11 @@ module MastercardCoreSdk
75
74
 
76
75
  ERR_MSG_PRIVATE_KEY = "Private key must be set through MasterCardApiConfiguration class."
77
76
  ERR_MSG_CONSUMER_KEY = "Consumer key must be set through MasterCardApiConfiguration class."
78
- ERR_MSG_NULL_HEADER = "Found null value for API-Call-Tracker or User-Agent header."
77
+ ERR_MSG_NULL_HEADER = "Found null value for User-Agent header."
79
78
  ERR_MSG_NULL_SERVICE = "Found API tracker service is not implemented."
80
- ERR_MSG_NULL_REQUEST = "Request can not be null."
81
- ERR_MSG_NULL_RESPONSE = "Response can not be null."
82
- ERR_MSG_OAUTH_HEADER = "Parameters can not be null."
79
+ ERR_MSG_NULL_REQUEST = "Request cannot be null."
80
+ ERR_MSG_NULL_RESPONSE = "Response cannot be null."
81
+ ERR_MSG_OAUTH_HEADER = "Parameters cannot be null."
83
82
  ERR_MSG_CONVERSION = "Conversion failed."
84
83
  ERR_MSG_API_CONFIG = "Api Config cannot be null."
85
84
  ERR_MSG_HOST_URL = "Host URL cannot be empty."
@@ -88,8 +87,9 @@ module MastercardCoreSdk
88
87
  NULL_OAUTH_PARAMETERS_ERROR = "Oauth parameters cannot be null."
89
88
 
90
89
  # Mime-types
91
- JSON_MIME_TYPE = "JSON"
92
- XML_MIME_TYPE = "XML"
93
- URLENCODED_MIME_TYPE = "WWW-FORM-URLENCODED"
90
+ CONTENT_TYPE_XML = "XML"
91
+ CONTENT_TYPE_JSON = "JSON"
92
+ CONTENT_TYPE_URL_ENCODED = "WWW-FORM-URLENCODED"
93
+ ERR_MSG_CONTENT_TYPE = "Content-type is not supported :"
94
94
 
95
95
  end
@@ -36,7 +36,7 @@ module MastercardCoreSdk
36
36
  #
37
37
  # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
38
38
  def response_body_converter(response, return_type)
39
- body = response.body
39
+ body = response
40
40
  return nil if body.nil? || body.empty?
41
41
  begin
42
42
  data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
@@ -9,19 +9,15 @@ module MastercardCoreSdk
9
9
  @@logger = Logging.logger[self]
10
10
  @@content_handlers = {}
11
11
 
12
- CONTENT_TYPE_XML = "XML"
13
- CONTENT_TYPE_JSON = "JSON"
14
- CONTENT_TYPE_URL_ENCODED = "WWW-FORM-URLENCODED"
15
- ERR_MSG_CONTENT_TYPE = "Content-type is not supported :"
16
-
17
12
  class << self
18
13
  include MastercardCoreSdk::Exceptions
19
14
 
20
- # Get converter as per content-type.
21
- # @param content_type String specifying content-type for request.
15
+ # Get converter as per mime-type.
16
+ # @param mime String specifying content-type for request.
22
17
  # @return [Hash]
23
- def get_converter(content_type)
18
+ def get_converter(mime)
24
19
  converter = nil
20
+ content_type = get_mime_sub_type(mime)
25
21
  if content_type
26
22
  return @@content_handlers[content_type] if @@content_handlers.key?(content_type)
27
23
  if content_type.include?(CONTENT_TYPE_XML)
@@ -50,6 +46,45 @@ module MastercardCoreSdk
50
46
  end
51
47
  end
52
48
 
49
+ # Return sub-type for the mime.
50
+ # @param mime String specifying mime-type.
51
+ # @return [String]
52
+ def get_mime_sub_type(mime)
53
+ mime_sub_type = ""
54
+ if json_mime?(mime)
55
+ mime_sub_type = CONTENT_TYPE_JSON
56
+ elsif xml_mime?(mime)
57
+ mime_sub_type = CONTENT_TYPE_XML
58
+ elsif urlencoded_mime?(mime)
59
+ mime_sub_type = CONTENT_TYPE_URL_ENCODED
60
+ else
61
+ @@logger.debug "#{ERR_MSG_CONTENT_TYPE} #{mime}"
62
+ raise SDKConversionError.new(:error_message => "#{ERR_MSG_CONTENT_TYPE} #{mime}", :source => self.class)
63
+ end
64
+ return mime_sub_type
65
+ end
66
+
67
+ # Check if the given MIME is a JSON mime.
68
+ # @param mime String specifying mime-type.
69
+ # @return [Boolean]
70
+ def json_mime?(mime)
71
+ !!(mime =~ /(json|javascript)/i)
72
+ end
73
+
74
+ # Check if the given MIME is a XML mime.
75
+ # @param mime String specifying mime-type.
76
+ # @return [Boolean]
77
+ def xml_mime?(mime)
78
+ !!(mime =~ /xml/i)
79
+ end
80
+
81
+ # Check if the given MIME is a WWW-FORM-URLENCODED mime.
82
+ # @param mime String specifying mime-type.
83
+ # @return [Boolean]
84
+ def urlencoded_mime?(mime)
85
+ !!(mime =~ /www-form-urlencoded/i)
86
+ end
87
+
53
88
  end
54
89
  end
55
90
  end
@@ -33,8 +33,8 @@ module MastercardCoreSdk
33
33
  end
34
34
  log_str += NEWLINE
35
35
 
36
- @@logger.info request_api_info
37
- @@logger.debug log_str
36
+ @@logger.info request_api_info
37
+ @@logger.debug log_str
38
38
  else
39
39
  @@logger.error ERR_MSG_NULL_REQUEST
40
40
  raise SDKValidationError.new(ERR_MSG_NULL_REQUEST)
@@ -68,7 +68,7 @@ module MastercardCoreSdk
68
68
  if response.response_body
69
69
  response_body = response.response_body
70
70
 
71
- xml_mime = !!(response.headers['Content-Type'] =~ /\Aapplication\/xml(;.*)?\z/i)
71
+ xml_mime = !!(response.headers['Content-Type'] =~ /xml/i)
72
72
  if xml_mime && response_body.include?("AccountNumber")
73
73
  response_body = mask_data(response_body)
74
74
  end
@@ -25,7 +25,6 @@ module MastercardCoreSdk
25
25
  ERR_UNKN_REASON = "GENERAL_ERROR"
26
26
  ERR_INTERNAL = "INTERNAL_PROCESSING_ERROR"
27
27
  SEP_COLON = "]: "
28
- OAUTH_MIME_TYPE = "WWW-FORM-URLENCODED"
29
28
  ERR_MSG_RES_PARSE = "Exception occurred during response parsing."
30
29
 
31
30
  # Raise custom error as per response error object.
@@ -50,8 +49,8 @@ module MastercardCoreSdk
50
49
  raise SDKResponseError.new(:errors_object => errors, :status_code => 400)
51
50
  end
52
51
 
53
- content_type = mime_sub_type(error_response.response.headers['Content-Type']) rescue nil
54
-
52
+ content_type = error_response.response.headers['Content-Type'] rescue nil
53
+
55
54
  begin
56
55
  converter = SDKConverterFactory.get_converter(content_type)
57
56
  errors = converter.response_body_converter(response_body, Errors)
@@ -60,7 +59,7 @@ module MastercardCoreSdk
60
59
  rescue SDKConversionError => err
61
60
  # For request and access token call if any require parameter missing in header server send response as encodedURL.
62
61
  # Below code set the received response as description and raise Errors object.
63
- if content_type.include?(OAUTH_MIME_TYPE)
62
+ if SDKConverterFactory.get_mime_sub_type(content_type).include?(CONTENT_TYPE_URL_ENCODED)
64
63
  description = response_body
65
64
  else
66
65
  description = err.message
@@ -87,43 +86,6 @@ module MastercardCoreSdk
87
86
  error = Error.new(:description => description, :reason_code => reason_code, :source => source, :recoverable => false)
88
87
  return Errors.new(:error => [error])
89
88
  end
90
-
91
- def mime_sub_type(content_type)
92
- mime_type = ""
93
- if json_mime?(content_type)
94
- mime_type = JSON_MIME_TYPE
95
- elsif xml_mime?(content_type)
96
- mime_type = XML_MIME_TYPE
97
- elsif urlencoded_mime?(content_type)
98
- mime_type = URLENCODED_MIME_TYPE
99
- end
100
- return mime_type
101
- end
102
-
103
- # Check if the given MIME is a JSON MIME.
104
- # JSON MIME examples:
105
- # application/json
106
- # application/json; charset=UTF8
107
- # APPLICATION/JSON
108
- def json_mime?(mime)
109
- !!(mime =~ /\Aapplication\/json(;.*)?\z/i)
110
- end
111
-
112
- # Check if the given MIME is a XML MIME.
113
- # XML MIME examples:
114
- # application/xml
115
- # application/xml; charset=UTF8
116
- # APPLICATION/XML
117
- def xml_mime?(mime)
118
- !!(mime =~ /\Aapplication\/xml(;.*)?\z/i)
119
- end
120
-
121
- # Check if the given MIME is a X-WWW-FORM_URLENCODED MIME.
122
- # XML MIME examples:
123
- # application/x-www-form-urlencoded
124
- def urlencoded_mime?(mime)
125
- !!(mime =~ /\Aapplication\/x-www-form-urlencoded(;.*)?\z/i)
126
- end
127
89
 
128
90
  end
129
91
  end
@@ -30,13 +30,12 @@ module MastercardCoreSdk
30
30
  end
31
31
  end
32
32
 
33
- # Method to build API call tracking header
33
+ # Method to build User-Agent header to track API information.
34
34
  def build(request)
35
35
  api_tracker_string = BASE_SDK_VERSION + @base_sdk_version + SEPERATOR
36
36
  api_tracker_string += @api_tracker.tracking_info
37
37
 
38
- request.options[:headers].merge!({ API_TRACKER_HEADER => api_tracker_string })
39
- request.options[:headers].merge!({ USER_AGENT_HEADER => @api_tracker.user_agent_info })
38
+ request.options[:headers].merge!({ USER_AGENT_HEADER => api_tracker_string })
40
39
  end
41
40
 
42
41
  end
@@ -19,7 +19,7 @@ module MastercardCoreSdk
19
19
  }
20
20
  end
21
21
 
22
- #Initializing object attributes with response parameters
22
+ #Initializing object attributes.
23
23
  def initialize(attributes = {})
24
24
  return unless attributes.is_a?(Hash)
25
25
  # convert string to symbol for hash key
@@ -35,10 +35,8 @@ module MastercardCoreSdk
35
35
  def ==(o)
36
36
  return true if self.equal?(o)
37
37
  self.class == o.class &&
38
- currency_code == o.currency_code &&
39
- subtotal == o.subtotal &&
40
- shopping_cart_item == o.shopping_cart_item &&
41
- extension_point == o.extension_point
38
+ oauth_token == o.oauth_token &&
39
+ oauth_token_secret == o.oauth_token_secret
42
40
  end
43
41
 
44
42
  # @see the `==` method
@@ -48,7 +46,7 @@ module MastercardCoreSdk
48
46
 
49
47
  # Calculate hash code according to all attributes.
50
48
  def hash
51
- [currency_code, subtotal, shopping_cart_item, extension_point].hash
49
+ [oauth_token, oauth_token_secret].hash
52
50
  end
53
51
 
54
52
  # build the object from hash
@@ -19,16 +19,8 @@ module MastercardCoreSdk
19
19
  # Attribute mapping from ruby-style variable name to JSON key.
20
20
  def self.attribute_map
21
21
  {
22
- :'name' => :'Name',
23
- :'value' => :'Value'
24
- }
25
- end
26
-
27
- # Attribute type mapping.
28
- def self.swagger_types
29
- {
30
- :'name' => :'String',
31
- :'value' => :'String'
22
+ :name => :Name,
23
+ :value => :Value
32
24
  }
33
25
  end
34
26
 
@@ -38,12 +30,12 @@ module MastercardCoreSdk
38
30
  # convert string to symbol for hash key
39
31
  attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
40
32
 
41
- if attributes.has_key?(:Name) || attributes.has_key?(:name)
42
- self.name = attributes[:Name] || attributes[:name]
33
+ if attributes.has_key?(:name)
34
+ self.name = attributes[:name]
43
35
  end
44
36
 
45
- if attributes.has_key?(:Value) || attributes.has_key?(:value)
46
- self.value = attributes[:Value] || attributes[:value]
37
+ if attributes.has_key?(:value)
38
+ self.value = attributes[:value]
47
39
  end
48
40
  end
49
41
 
@@ -68,7 +60,7 @@ module MastercardCoreSdk
68
60
  # build the object from hash
69
61
  def build_from_hash(attributes)
70
62
  return nil unless attributes.is_a?(Hash)
71
- self.class.swagger_types.each_pair do |key, type|
63
+ self.class.datatype_map.each_pair do |key, type|
72
64
  if type =~ /^Array<(.*)>/i
73
65
  if attributes[self.class.attribute_map[key]].is_a?(Array)
74
66
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
@@ -157,6 +149,14 @@ module MastercardCoreSdk
157
149
  end
158
150
 
159
151
  private
152
+
153
+ # Attribute type mapping.
154
+ def self.datatype_map
155
+ {
156
+ :name => 'String',
157
+ :value => 'String'
158
+ }
159
+ end
160
160
 
161
161
  def after_parse
162
162
  self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
@@ -17,14 +17,7 @@ module MastercardCoreSdk
17
17
  # Attribute mapping from ruby-style variable name to JSON key.
18
18
  def self.attribute_map
19
19
  {
20
- :'detail' => :'Detail'
21
- }
22
- end
23
-
24
- # Attribute type mapping.
25
- def self.swagger_types
26
- {
27
- :'detail' => :'Array<Detail>'
20
+ :detail => :Detail
28
21
  }
29
22
  end
30
23
 
@@ -34,8 +27,8 @@ module MastercardCoreSdk
34
27
  # convert string to symbol for hash key
35
28
  attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
36
29
 
37
- if attributes.has_key?(:Detail) || attributes.has_key?(:detail)
38
- if (value = attributes[:Detail] || attributes[:detail]).is_a?(Array)
30
+ if attributes.has_key?(:detail)
31
+ if attributes[:detail].is_a?(Array)
39
32
  self.detail = value
40
33
  end
41
34
  end
@@ -61,7 +54,7 @@ module MastercardCoreSdk
61
54
  # build the object from hash
62
55
  def build_from_hash(attributes)
63
56
  return nil unless attributes.is_a?(Hash)
64
- self.class.swagger_types.each_pair do |key, type|
57
+ self.class.datatype_map.each_pair do |key, type|
65
58
  if type =~ /^Array<(.*)>/i
66
59
  if attributes[self.class.attribute_map[key]].is_a?(Array)
67
60
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
@@ -92,9 +85,9 @@ module MastercardCoreSdk
92
85
  value.to_f
93
86
  when :BOOLEAN
94
87
  if value =~ /^(true|t|yes|y|1)$/i
95
- true
88
+ true
96
89
  else
97
- false
90
+ false
98
91
  end
99
92
  when /\AArray<(?<inner_type>.+)>\z/
100
93
  inner_type = Regexp.last_match[:inner_type]
@@ -108,7 +101,7 @@ module MastercardCoreSdk
108
101
  end
109
102
  end
110
103
  else # model
111
- _model = Mpass.const_get(type).new
104
+ _model = MastercardCoreSdk.const_get(type).new
112
105
  _model.build_from_hash(value)
113
106
  end
114
107
  end
@@ -150,6 +143,13 @@ module MastercardCoreSdk
150
143
  end
151
144
 
152
145
  private
146
+
147
+ # Attribute type mapping.
148
+ def self.datatype_map
149
+ {
150
+ :detail => 'Array<Detail>'
151
+ }
152
+ end
153
153
 
154
154
  def after_parse
155
155
  self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
@@ -38,24 +38,12 @@ module MastercardCoreSdk
38
38
  # Attribute mapping from ruby-style variable name to JSON key.
39
39
  def self.attribute_map
40
40
  {
41
- :'description' => :'Description',
42
- :'reason_code' => :'ReasonCode',
43
- :'recoverable' => :'Recoverable',
44
- :'source' => :'Source',
45
- :'details' => :'Details',
46
- :'extension_point' => :'ExtensionPoint'
47
- }
48
- end
49
-
50
- # Attribute type mapping.
51
- def self.swagger_types
52
- {
53
- :'description' => :'String',
54
- :'reason_code' => :'String',
55
- :'recoverable' => :'BOOLEAN',
56
- :'source' => :'String',
57
- :'details' => :'Details',
58
- :'extension_point' => :'ExtensionPoint'
41
+ :description => :Description,
42
+ :reason_code => :ReasonCode,
43
+ :recoverable => :Recoverable,
44
+ :source => :Source,
45
+ :details => :Details,
46
+ :extension_point => :ExtensionPoint
59
47
  }
60
48
  end
61
49
 
@@ -65,28 +53,28 @@ module MastercardCoreSdk
65
53
  # convert string to symbol for hash key
66
54
  attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
67
55
 
68
- if attributes.has_key?(:Description) || attributes.has_key?(:description)
69
- self.description = attributes[:Description] || attributes[:description]
56
+ if attributes.has_key?(:description)
57
+ self.description = attributes[:description]
70
58
  end
71
59
 
72
- if attributes.has_key?(:ReasonCode) || attributes.has_key?(:reason_code)
73
- self.reason_code = attributes[:ReasonCode] || attributes[:reason_code]
60
+ if attributes.has_key?(:reason_code)
61
+ self.reason_code = attributes[:reason_code]
74
62
  end
75
63
 
76
- if attributes.has_key?(:Recoverable) || attributes.has_key?(:recoverable)
77
- self.recoverable = attributes[:Recoverable] || attributes[:recoverable]
64
+ if attributes.has_key?(:recoverable)
65
+ self.recoverable = attributes[:recoverable]
78
66
  end
79
67
 
80
- if attributes.has_key?(:Source) || attributes.has_key?(:source)
81
- self.source = attributes[:Source] || attributes[:source]
68
+ if attributes.has_key?(:source)
69
+ self.source = attributes[:source]
82
70
  end
83
71
 
84
- if attributes.has_key?(:Details) || attributes.has_key?(:details)
85
- self.details = attributes[:Details] || attributes[:details]
72
+ if attributes.has_key?(:details)
73
+ self.details = attributes[:details]
86
74
  end
87
75
 
88
- if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
89
- self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
76
+ if attributes.has_key?(:extension_point)
77
+ self.extension_point = attributes[:extension_point]
90
78
  end
91
79
  end
92
80
 
@@ -115,7 +103,7 @@ module MastercardCoreSdk
115
103
  # build the object from hash
116
104
  def build_from_hash(attributes)
117
105
  return nil unless attributes.is_a?(Hash)
118
- self.class.swagger_types.each_pair do |key, type|
106
+ self.class.datatype_map.each_pair do |key, type|
119
107
  if type =~ /^Array<(.*)>/i
120
108
  if attributes[self.class.attribute_map[key]].is_a?(Array)
121
109
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
@@ -146,9 +134,9 @@ module MastercardCoreSdk
146
134
  value.to_f
147
135
  when :BOOLEAN
148
136
  if value =~ /^(true|t|yes|y|1)$/i
149
- true
137
+ true
150
138
  else
151
- false
139
+ false
152
140
  end
153
141
  when /\AArray<(?<inner_type>.+)>\z/
154
142
  inner_type = Regexp.last_match[:inner_type]
@@ -162,7 +150,7 @@ module MastercardCoreSdk
162
150
  end
163
151
  end
164
152
  else # model
165
- _model = Mpass.const_get(type).new
153
+ _model = MastercardCoreSdk.const_get(type).new
166
154
  _model.build_from_hash(value)
167
155
  end
168
156
  end
@@ -197,13 +185,25 @@ module MastercardCoreSdk
197
185
  value.each { |k, v| hash[k] = _to_hash(v) }
198
186
  end
199
187
  elsif value.respond_to? :to_hash
200
- value.to_hash
188
+ value.to_hash
201
189
  else
202
- value
190
+ value
203
191
  end
204
192
  end
205
193
 
206
194
  private
195
+
196
+ # Attribute type mapping.
197
+ def self.datatype_map
198
+ {
199
+ :description => 'String',
200
+ :reason_code => 'String',
201
+ :recoverable => 'BOOLEAN',
202
+ :source => 'String',
203
+ :details => 'Details',
204
+ :extension_point => 'ExtensionPoint'
205
+ }
206
+ end
207
207
 
208
208
  def after_parse
209
209
  self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
@@ -16,14 +16,7 @@ module MastercardCoreSdk
16
16
  # Attribute mapping from ruby-style variable name to JSON key.
17
17
  def self.attribute_map
18
18
  {
19
- :'error' => :'Error'
20
- }
21
- end
22
-
23
- # Attribute type mapping.
24
- def self.swagger_types
25
- {
26
- :'error' => :'Array<Error>'
19
+ :error => :Error
27
20
  }
28
21
  end
29
22
 
@@ -33,8 +26,8 @@ module MastercardCoreSdk
33
26
  # convert string to symbol for hash key
34
27
  attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
35
28
 
36
- if attributes.has_key?(:Error) || attributes.has_key?(:error)
37
- self.error = attributes[:Error] || attributes[:error]
29
+ if attributes.has_key?(:error)
30
+ self.error = attributes[:error]
38
31
  end
39
32
  end
40
33
 
@@ -69,7 +62,7 @@ module MastercardCoreSdk
69
62
  # build the object from hash
70
63
  def build_from_hash(attributes)
71
64
  return nil unless attributes.is_a?(Hash)
72
- self.class.swagger_types.each_pair do |key, type|
65
+ self.class.datatype_map.each_pair do |key, type|
73
66
  if type =~ /^Array<(.*)>/i
74
67
  if attributes[self.class.attribute_map[key]].is_a?(Array)
75
68
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
@@ -151,13 +144,20 @@ module MastercardCoreSdk
151
144
  value.each { |k, v| hash[k] = _to_hash(v) }
152
145
  end
153
146
  elsif value.respond_to? :to_hash
154
- value.to_hash
147
+ value.to_hash
155
148
  else
156
- value
149
+ value
157
150
  end
158
151
  end
159
152
 
160
153
  private
154
+
155
+ # Attribute type mapping.
156
+ def self.datatype_map
157
+ {
158
+ :error => 'Array<Error>'
159
+ }
160
+ end
161
161
 
162
162
  def after_parse
163
163
  self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
@@ -12,14 +12,7 @@ module MastercardCoreSdk
12
12
  # Attribute mapping from ruby-style variable name to JSON key.
13
13
  def self.attribute_map
14
14
  {
15
- :'any' => :'any'
16
- }
17
- end
18
-
19
- # Attribute type mapping.
20
- def self.swagger_types
21
- {
22
- :'any' => :'Object'
15
+ :any => :any
23
16
  }
24
17
  end
25
18
 
@@ -55,7 +48,7 @@ module MastercardCoreSdk
55
48
  # build the object from hash
56
49
  def build_from_hash(attributes)
57
50
  return nil unless attributes.is_a?(Hash)
58
- self.class.swagger_types.each_pair do |key, type|
51
+ self.class.datatype_map.each_pair do |key, type|
59
52
  if type =~ /^Array<(.*)>/i
60
53
  if attributes[self.class.attribute_map[key]].is_a?(Array)
61
54
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
@@ -102,7 +95,7 @@ module MastercardCoreSdk
102
95
  end
103
96
  end
104
97
  else # model
105
- _model = Mpass.const_get(type).new
98
+ _model = MastercardCoreSdk.const_get(type).new
106
99
  _model.build_from_hash(value)
107
100
  end
108
101
  end
@@ -137,13 +130,20 @@ module MastercardCoreSdk
137
130
  value.each { |k, v| hash[k] = _to_hash(v) }
138
131
  end
139
132
  elsif value.respond_to? :to_hash
140
- value.to_hash
133
+ value.to_hash
141
134
  else
142
- value
135
+ value
143
136
  end
144
137
  end
145
138
 
146
139
  private
140
+
141
+ # Attribute type mapping.
142
+ def self.datatype_map
143
+ {
144
+ :any => 'Object'
145
+ }
146
+ end
147
147
 
148
148
  def after_parse
149
149
  self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
@@ -52,10 +52,11 @@ module MastercardCoreSdk
52
52
  def ==(o)
53
53
  return true if self.equal?(o)
54
54
  self.class == o.class &&
55
- currency_code == o.currency_code &&
56
- subtotal == o.subtotal &&
57
- shopping_cart_item == o.shopping_cart_item &&
58
- extension_point == o.extension_point
55
+ xoauth_request_auth_url == o.xoauth_request_auth_url &&
56
+ oauth_token == o.oauth_token &&
57
+ oauth_token_secret == o.oauth_token_secret &&
58
+ oauth_expires_in == o.oauth_expires_in &&
59
+ oauth_callback_confirmed == o.oauth_callback_confirmed
59
60
  end
60
61
 
61
62
  # @see the `==` method
@@ -6,12 +6,12 @@ module MastercardCoreSdk
6
6
  module ApiTracker
7
7
  include MastercardCoreSdk::Exceptions
8
8
 
9
- # Method to be overridden by the class for API-Call-Tracker header
9
+ # Method to be overridden by the class for tracking information header.
10
10
  def tracking_info
11
11
  raise SDKValidationError.new(LOG_MSG_TRACKING_INFO_ERROR)
12
12
  end
13
13
 
14
- # Method to be overridden by the class for user-agent info header
14
+ # Method to be overridden by the class for user-agent information header.
15
15
  def user_agent_info
16
16
  raise SDKValidationError.new(LOG_MSG_USER_AGENT_ERROR)
17
17
  end
@@ -33,7 +33,7 @@ module MastercardCoreSdk
33
33
  end
34
34
 
35
35
  # Overriding {ApiTracker#tracking_info} method.
36
- #
36
+ # Get tracking information set in User-Agent header.
37
37
  # @return [String]
38
38
  def tracking_info
39
39
  api_tracker_string = LANG_NAME + language + SEPERATOR + LANG_VERSION + language_version
@@ -1,3 +1,3 @@
1
1
  module MastercardCoreSdk
2
- VERSION = "1.1.3"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mastercard_core_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - MasterCard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-23 00:00:00.000000000 Z
11
+ date: 2016-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler