Class: Freemium::Response

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

Overview

used to encapsulate the success/failure/details of a response from some gateway. intended to be independent of the details of communication (e.g. Freemium::Gateways::BrainTree::Post).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(success, raw_data = {}) ⇒ Response

Returns a new instance of Response.



12
13
14
# File 'lib/freemium/response.rb', line 12

def initialize(success, raw_data = {})
  @success, @raw_data = success, raw_data
end

Instance Attribute Details

#billing_keyObject

the related billing key, if appropriate



10
11
12
# File 'lib/freemium/response.rb', line 10

def billing_key
  @billing_key
end

#messageObject

may contain a description of the response. should contain an explanation if the response was not a success.



8
9
10
# File 'lib/freemium/response.rb', line 8

def message
  @message
end

#raw_dataObject (readonly)

a gateway-specific hash of raw data related to the request.



6
7
8
# File 'lib/freemium/response.rb', line 6

def raw_data
  @raw_data
end

Instance Method Details

#[](key) ⇒ Object



20
21
22
# File 'lib/freemium/response.rb', line 20

def [](key)
  raw_data[key]
end

#success?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/freemium/response.rb', line 16

def success?
  @success
end