Class: Square::Devices::Codes::Client
- Inherits:
-
Object
- Object
- Square::Devices::Codes::Client
- Defined in:
- lib/square/devices/codes/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Square::Types::CreateDeviceCodeResponse
Creates a DeviceCode that can be used to login to a Square Terminal device to enter the connected terminal mode.
-
#get(request_options: {}, **params) ⇒ Square::Types::GetDeviceCodeResponse
Retrieves DeviceCode with the associated ID.
- #initialize(client:) ⇒ Square::Devices::Codes::Client constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListDeviceCodesResponse
Lists all DeviceCodes associated with the merchant.
Constructor Details
#initialize(client:) ⇒ Square::Devices::Codes::Client
8 9 10 |
# File 'lib/square/devices/codes/client.rb', line 8 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Square::Types::CreateDeviceCodeResponse
Creates a DeviceCode that can be used to login to a Square Terminal device to enter the connected terminal mode.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/square/devices/codes/client.rb', line 38 def create(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/devices/codes", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::CreateDeviceCodeResponse.load(_response.body) end raise _response.body end |
#get(request_options: {}, **params) ⇒ Square::Types::GetDeviceCodeResponse
Retrieves DeviceCode with the associated ID.
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/square/devices/codes/client.rb', line 56 def get(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/devices/codes/#{params[:id]}" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::GetDeviceCodeResponse.load(_response.body) end raise _response.body end |
#list(request_options: {}, **params) ⇒ Square::Types::ListDeviceCodesResponse
Lists all DeviceCodes associated with the merchant.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/square/devices/codes/client.rb', line 15 def list(request_options: {}, **params) _query_param_names = %w[cursor location_id product_type status] _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/devices/codes", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::ListDeviceCodesResponse.load(_response.body) end raise _response.body end |