Class: SlidePay::Response

Inherits:
String
  • Object
show all
Defined in:
lib/slidepay/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_json = nil) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
12
# File 'lib/slidepay/response.rb', line 7

def initialize(response_json=nil)
  if response_json
    replace response_json
    parse_object_from_json
  end
end

Instance Attribute Details

#customObject

Returns the value of attribute custom.



4
5
6
# File 'lib/slidepay/response.rb', line 4

def custom
  @custom
end

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/slidepay/response.rb', line 4

def data
  @data
end

#data_md5Object

Returns the value of attribute data_md5.



4
5
6
# File 'lib/slidepay/response.rb', line 4

def data_md5
  @data_md5
end

#endpointObject

response metadata fields



35
36
37
# File 'lib/slidepay/response.rb', line 35

def endpoint
  @endpoint
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/slidepay/response.rb', line 4

def id
  @id
end

#methodObject

Returns the value of attribute method.



4
5
6
# File 'lib/slidepay/response.rb', line 4

def method
  @method
end

#millisecondsObject

Returns the value of attribute milliseconds.



4
5
6
# File 'lib/slidepay/response.rb', line 4

def milliseconds
  @milliseconds
end

#objObject

Returns the value of attribute obj.



4
5
6
# File 'lib/slidepay/response.rb', line 4

def obj
  @obj
end

#operationObject

Returns the value of attribute operation.



4
5
6
# File 'lib/slidepay/response.rb', line 4

def operation
  @operation
end

#successObject

Returns the value of attribute success.



4
5
6
# File 'lib/slidepay/response.rb', line 4

def success
  @success
end

#timezoneObject

Returns the value of attribute timezone.



4
5
6
# File 'lib/slidepay/response.rb', line 4

def timezone
  @timezone
end

Instance Method Details

#errorObject

error fields



40
41
42
43
44
45
46
# File 'lib/slidepay/response.rb', line 40

def error
  if was_successful? == false
    @data
  else
    nil
  end
end

#error_codeObject



48
49
50
51
52
# File 'lib/slidepay/response.rb', line 48

def error_code
  if error
    @data['error_code']
  end
end

#error_textObject



54
55
56
57
58
# File 'lib/slidepay/response.rb', line 54

def error_text
  if error
    @data['error_text']
  end
end

#parse_object_from_jsonObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/slidepay/response.rb', line 14

def parse_object_from_json
  object = MultiJson.decode(self)

  @success = object['success']
  @custom = object['custom']
  @operation = object['operation']
  @endpoint = object['endpoint']
  @timezone = object['timezone']
  @method = object['method']
  @obj = object['obj']
  @id = object['id']
  @milliseconds = object['milliseconds']
  @data = object['data']
  @data_md5 = object['data_md5']
end

#was_successful?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/slidepay/response.rb', line 30

def was_successful?
  @success == true
end