Module: SlidePay
- Defined in:
- lib/slidepay.rb,
lib/slidepay/util.rb,
lib/slidepay/client.rb,
lib/slidepay/config.rb,
lib/slidepay/version.rb,
lib/slidepay/response.rb,
lib/slidepay/ach/balance.rb,
lib/slidepay/ach/resource.rb,
lib/slidepay/ach/retrieval.rb,
lib/slidepay/ach/settlement.rb,
lib/slidepay/reports/report.rb,
lib/slidepay/resources/api_key.rb,
lib/slidepay/resources/company.rb,
lib/slidepay/resources/payment.rb,
lib/slidepay/reports/put_report.rb,
lib/slidepay/resources/customer.rb,
lib/slidepay/resources/location.rb,
lib/slidepay/reports/post_report.rb,
lib/slidepay/resources/user_master.rb,
lib/slidepay/reports/account_report.rb,
lib/slidepay/reports/payment_report.rb,
lib/slidepay/resources/api_resource.rb,
lib/slidepay/resources/bank_account.rb
Defined Under Namespace
Modules: ACH, Util
Classes: AccountReport, ApiKey, ApiResource, BankAccount, Client, Company, Customer, Location, Payment, PaymentReport, PostReport, PutReport, Report, Response, UserMaster
Constant Summary
collapse
- ENDPOINT_SUFFIX =
'/rest.svc/API/'
- SUPERVISOR_URL =
'https://supervisor.getcube.com:65532/rest.svc/API/'
- PROD_API_URL =
'https://api.getcube.com:65532/rest.svc/API/'
- DEV_API_URL =
'https://dev.getcube.com:65532/rest.svc/API/'
- DEBUG =
false
- VERSION =
"0.0.13"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
39
40
41
|
# File 'lib/slidepay.rb', line 39
def api_key
@api_key
end
|
.endpoint ⇒ Object
Returns the value of attribute endpoint.
39
40
41
|
# File 'lib/slidepay.rb', line 39
def endpoint
@endpoint
end
|
.token ⇒ Object
Returns the value of attribute token.
39
40
41
|
# File 'lib/slidepay.rb', line 39
def token
@token
end
|
Class Method Details
.authenticate(email, password) ⇒ Object
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/slidepay.rb', line 64
def authenticate(email, password)
response = retrieve_token(email, password)
if response.was_successful?
@endpoint = "#{response.endpoint}"
@token = response.data
true
else
false
end
end
|
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/slidepay.rb', line 143
def configure(options_hash={})
if options_hash[:api_key]
@api_key = options_hash[:api_key]
end
if options_hash[:token]
@token = options_hash[:token]
end
if options_hash[:endpoint]
@endpoint = options_hash[:endpoint]
elsif options_hash[:development] == true
@endpoint = DEV_API_URL
else
@endpoint = SUPERVISOR_URL
end
end
|
.delete(request_options_hash) ⇒ Object
135
136
137
138
139
140
141
|
# File 'lib/slidepay.rb', line 135
def delete(request_options_hash)
if request_options_hash.is_a? String
request_options_hash = { :path => request_options_hash }
end
request("DELETE", request_options_hash)
end
|
.get(request_options_hash) ⇒ Object
119
120
121
122
123
124
125
|
# File 'lib/slidepay.rb', line 119
def get(request_options_hash)
if request_options_hash.is_a? String
request_options_hash = { :path => request_options_hash }
end
request("GET", request_options_hash)
end
|
.get_auth_option(request_options_hash) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/slidepay.rb', line 49
def get_auth_option(request_options_hash)
options = {}
if request_options_hash[:token]
options["x-cube-token"] = request_options_hash[:token]
elsif request_options_hash[:api_key]
options["x-cube-api-key"] = request_options_hash[:api_key]
elsif @token
options["x-cube-token"] = @token
elsif @api_key
options["x-cube-api-key"] = @api_key
end
options
end
|
.get_endpoint_option(options) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/slidepay.rb', line 41
def get_endpoint_option(options)
if options[:endpoint]
options[:endpoint]
else
@endpoint
end
end
|
.post(request_options_hash) ⇒ Object
127
128
129
|
# File 'lib/slidepay.rb', line 127
def post(request_options_hash)
request("POST", request_options_hash)
end
|
.put(request_options_hash) ⇒ Object
131
132
133
|
# File 'lib/slidepay.rb', line 131
def put(request_options_hash)
request("PUT", request_options_hash)
end
|
.request(type, request_options_hash) ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/slidepay.rb', line 83
def request(type, request_options_hash)
options = { "Content-Type" => "application/json" }
options.merge! get_auth_option request_options_hash
if request_options_hash[:email]
options["x-cube-email"] = request_options_hash[:email]
end
if request_options_hash[:password]
options["x-cube-password"] = request_options_hash[:password]
end
url = "#{get_endpoint_option(request_options_hash)}#{request_options_hash[:path]}"
data = request_options_hash[:data]
begin
case type
when "GET"
response = RestClient.get url, options
when "PUT"
response = RestClient.put url, data, options
when "POST"
response = RestClient.post url, data, options
when "DELETE"
response = RestClient.delete url, options
else
raise Exception.new("Invalid request type specified")
end
rescue => e
response = e.response
end
Response.new(response)
end
|
.retrieve_endpoint(email) ⇒ Object
79
80
81
|
# File 'lib/slidepay.rb', line 79
def retrieve_endpoint(email)
get(path: "endpoint", :email => email)
end
|
.retrieve_token(email, password) ⇒ Object
75
76
77
|
# File 'lib/slidepay.rb', line 75
def retrieve_token(email, password)
get(path: "login", :email => email, :password => password)
end
|