Class: SlimpayClient::App
- Defined in:
- lib/slimpay_client/app.rb
Overview
Used only to get and set callback URLs.
Instance Method Summary collapse
-
#cancel_url(url) ⇒ Object
Change the cancelUrl ===== Example: app = SlimpayClient::App.new app.cancel_url = “mywebsite.com/client/123/”.
-
#change_urls(urls_params) ⇒ Object
Change the notification and return URLs.
-
#failure_url(url) ⇒ Object
Change the failureUrl ===== Example: app = SlimpayClient::App.new app.failure_url = “mywebsite.com/client/123/”.
-
#initialize(username = nil, password = nil) ⇒ App
constructor
Prepare an admin token for app requests.
-
#notify_url(url) ⇒ Object
Change the notifyUrl.
-
#return_url(url) ⇒ Object
Change the returnUrl ===== Example: app = SlimpayClient::App.new app.return_url = “mywebsite.com/client/123/”.
-
#success_url(url) ⇒ Object
Change the successUrl ===== Example: app = SlimpayClient::App.new app.success_url = “mywebsite.com/client/123/”.
Methods inherited from Resource
Methods inherited from Base
Constructor Details
#initialize(username = nil, password = nil) ⇒ App
Prepare an admin token for app requests.
Arguments:
username: Your SlimpayClient admin username
password: Your SlimpayClient admin password
9 10 11 12 13 14 15 16 |
# File 'lib/slimpay_client/app.rb', line 9 def initialize(username = nil, password = nil) init_config @username = username || SlimpayClient.configuration.username @password = password || SlimpayClient.configuration.password @basic_auth = {username: "#{@creditor_reference}##{@username}", password: @password} response = HTTParty.post(@token_endpoint, basic_auth: @basic_auth, body: ) @token = response['access_token'] end |
Instance Method Details
#cancel_url(url) ⇒ Object
Change the cancelUrl
Example:
app = SlimpayClient::App.new
app.cancel_url = "mywebsite.com/client/123/"
40 41 42 43 |
# File 'lib/slimpay_client/app.rb', line 40 def cancel_url(url) response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}", body: {cancelUrl: url}.to_json, headers: ) SlimpayClient.answer(response) end |
#change_urls(urls_params) ⇒ Object
Change the notification and return URLs.
Arguments:
successUrl: (String) URL to your app the customer is gonna be redirected to when leaving SlimpayClient platform (success).
failureUrl: (String) URL to your app the customer is gonna be redirected to when leaving SlimpayClient platform (failure).
cancelUrl: (String) URL to your app the customer is gonna be redirected to when leaving SlimpayClient platform (cancel).
returnUrl: (String) URL to your app the customer is gonna be redirected to when leaving SlimpayClient platform.
notifyUrl: (String) URL to your app SlimpayClient is gonna send a notification to, to confirm a Signature, a payment, etc.
68 69 70 71 |
# File 'lib/slimpay_client/app.rb', line 68 def change_urls(urls_params) response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}", body: urls_params.to_json, headers: ) SlimpayClient.answer(response) end |
#failure_url(url) ⇒ Object
Change the failureUrl
Example:
app = SlimpayClient::App.new
app.failure_url = "mywebsite.com/client/123/"
31 32 33 34 |
# File 'lib/slimpay_client/app.rb', line 31 def failure_url(url) response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}", body: {failureUrl: url}.to_json, headers: ) SlimpayClient.answer(response) end |
#notify_url(url) ⇒ Object
Change the notifyUrl
55 56 57 58 |
# File 'lib/slimpay_client/app.rb', line 55 def notify_url(url) response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}", body: {notifyUrl: url}.to_json, headers: ) SlimpayClient.answer(response) end |
#return_url(url) ⇒ Object
Change the returnUrl
Example:
app = SlimpayClient::App.new
app.return_url = "mywebsite.com/client/123/"
49 50 51 52 |
# File 'lib/slimpay_client/app.rb', line 49 def return_url(url) response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}", body: {returnUrl: url}.to_json, headers: ) SlimpayClient.answer(response) end |
#success_url(url) ⇒ Object
Change the successUrl
Example:
app = SlimpayClient::App.new
app.success_url = "mywebsite.com/client/123/"
22 23 24 25 |
# File 'lib/slimpay_client/app.rb', line 22 def success_url(url) response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}", body: {successUrl: url}.to_json, headers: ) SlimpayClient.answer(response) end |