Class: Bunq::DeviceServers

Inherits:
Object
  • Object
show all
Defined in:
lib/bunq/device_servers.rb

Overview

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ DeviceServers

client an instance of Bunq::Client



9
10
11
12
# File 'lib/bunq/device_servers.rb', line 9

def initialize(client)
  @resource = Bunq::Resource.new(client, "/v1/device-server")
  @client = client
end

Instance Method Details

#create(description, permitted_ips: nil) ⇒ Object

doc.bunq.com/api/1/call/device-server/method/post

You can add a wildcard IP by passing an array of the current IP, and the ‘*` character. E.g.: [’1.2.3.4’, ‘*’].

Parameters:

  • description (String)

    The description of this device server.

  • permitted_ips (Array|nil) (defaults to: nil)

    Array of permitted IP addresses.



22
23
24
25
26
27
28
29
30
# File 'lib/bunq/device_servers.rb', line 22

def create(description, permitted_ips: nil)
  fail ArgumentError.new('description is required') unless description
  fail 'Cannot create session, please add the api_key to your configuration' unless @client.configuration.api_key

  params = { description: description, secret: @client.configuration.api_key }
  params[:permitted_ips] = permitted_ips if permitted_ips

  @resource.post(params)['Response']
end

#indexObject



34
35
36
# File 'lib/bunq/device_servers.rb', line 34

def index
  @resource.get['Response']
end