Module: RocketGate
- Defined in:
- lib/rocketgate.rb,
lib/rocketgate/request.rb,
lib/rocketgate/version.rb,
lib/rocketgate/customer.rb,
lib/rocketgate/response.rb,
lib/rocketgate/connection.rb,
lib/rocketgate/credit_card.rb,
lib/rocketgate/transaction.rb,
lib/rocketgate/authorization.rb,
lib/rocketgate/configuration.rb
Defined Under Namespace
Modules: Hashable, ResponseCode, Validatable
Classes: Authorization, Configuration, Connection, CreditCard, Customer, Request, Response, Transaction
Constant Summary
collapse
- AuthorizationError =
Class.new(StandardError)
- ValidationError =
Class.new(StandardError)
- GatewayRequestError =
Class.new(StandardError)
- GatewayResponseError =
Class.new(StandardError)
- VERSION =
"0.0.2"
Class Method Summary
collapse
Class Method Details
.configuration ⇒ Object
23
24
25
|
# File 'lib/rocketgate.rb', line 23
def configuration
@configuration ||= Configuration.new
end
|
27
28
29
|
# File 'lib/rocketgate.rb', line 27
def configure
yield(configuration)
end
|
.connection ⇒ Object
31
32
33
34
35
36
|
# File 'lib/rocketgate.rb', line 31
def connection
configuration.validate!
@connection ||= Connection.new(configuration.request_host,
configuration.request_port,
configuration.request_path)
end
|
.reset! ⇒ Object
38
39
40
|
# File 'lib/rocketgate.rb', line 38
def reset!
@configuration, @connection = nil, nil
end
|
.send_request!(request) ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'lib/rocketgate.rb', line 42
def send_request!(request)
response = connection.make_request!(request.build_gateway_request)
if response.code.to_i == 200
return Response.from_xml(response.body)
else
raise GatewayRequestError.new("Unexpected status code in gateway response: #{response.code}")
end
end
|