Class: Square::Checkout::PaymentLinks::Client
- Inherits:
-
Object
- Object
- Square::Checkout::PaymentLinks::Client
- Defined in:
- lib/square/checkout/payment_links/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Square::Types::CreatePaymentLinkResponse
Creates a Square-hosted checkout page.
-
#delete(request_options: {}, **params) ⇒ Square::Types::DeletePaymentLinkResponse
Deletes a payment link.
-
#get(request_options: {}, **params) ⇒ Square::Types::GetPaymentLinkResponse
Retrieves a payment link.
- #initialize(client:) ⇒ Square::Checkout::PaymentLinks::Client constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListPaymentLinksResponse
Lists all payment links.
-
#update(request_options: {}, **params) ⇒ Square::Types::UpdatePaymentLinkResponse
Updates a payment link.
Constructor Details
#initialize(client:) ⇒ Square::Checkout::PaymentLinks::Client
8 9 10 |
# File 'lib/square/checkout/payment_links/client.rb', line 8 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Square::Types::CreatePaymentLinkResponse
Creates a Square-hosted checkout page. Applications can share the resulting payment link with their buyer to pay for goods and services.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/square/checkout/payment_links/client.rb', line 37 def create(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/online-checkout/payment-links", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::CreatePaymentLinkResponse.load(_response.body) end raise _response.body end |
#delete(request_options: {}, **params) ⇒ Square::Types::DeletePaymentLinkResponse
Deletes a payment link.
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/square/checkout/payment_links/client.rb', line 94 def delete(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "DELETE", path: "v2/online-checkout/payment-links/#{params[:id]}" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::DeletePaymentLinkResponse.load(_response.body) end raise _response.body end |
#get(request_options: {}, **params) ⇒ Square::Types::GetPaymentLinkResponse
Retrieves a payment link.
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/square/checkout/payment_links/client.rb', line 55 def get(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/online-checkout/payment-links/#{params[:id]}" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::GetPaymentLinkResponse.load(_response.body) end raise _response.body end |
#list(request_options: {}, **params) ⇒ Square::Types::ListPaymentLinksResponse
Lists all payment links.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/square/checkout/payment_links/client.rb', line 15 def list(request_options: {}, **params) _query_param_names = %w[cursor limit] _query = params.slice(*_query_param_names) params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/online-checkout/payment-links", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::ListPaymentLinksResponse.load(_response.body) end raise _response.body end |
#update(request_options: {}, **params) ⇒ Square::Types::UpdatePaymentLinkResponse
Updates a payment link. You can update the ‘payment_link` fields such as `description`, `checkout_options`, and `pre_populated_data`. You cannot update other fields such as the `order_id`, `version`, `URL`, or `timestamp` field.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/square/checkout/payment_links/client.rb', line 74 def update(request_options: {}, **params) _path_param_names = ["id"] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "PUT", path: "v2/online-checkout/payment-links/#{params[:id]}", body: params.except(*_path_param_names) ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::UpdatePaymentLinkResponse.load(_response.body) end raise _response.body end |