class FsApi::Client
Attributes
_last_response[R]
errors[RW]
password[R]
username[R]
Public Class Methods
new(username, password)
click to toggle source
# File lib/fs_api/client.rb, line 6 def initialize(username, password) @username = username @password = password end
Public Instance Methods
base_url()
click to toggle source
# File lib/fs_api/client.rb, line 11 def base_url "https://www.factuursturen.nl:443/api/v1" end
clients()
click to toggle source
# File lib/fs_api/client.rb, line 66 def clients FsApi::Service::Client.new(self) end
delete(path, headers={})
click to toggle source
# File lib/fs_api/client.rb, line 56 def delete(path, headers={}) uri = uri_for_path(path) http = Net::HTTP::Delete.new(uri.request_uri, self.headers.merge(headers)) perform(http) end
get(path, headers={})
click to toggle source
# File lib/fs_api/client.rb, line 36 def get(path, headers={}) uri = uri_for_path(path) http = Net::HTTP::Get.new(uri.request_uri, self.headers.merge(headers)) perform(http) end
headers()
click to toggle source
# File lib/fs_api/client.rb, line 25 def headers { 'Accept' => 'application/json', 'Content-Type' => 'application/json' } end
http()
click to toggle source
# File lib/fs_api/client.rb, line 15 def http @http ||= begin uri = uri_for_path(base_url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.scheme == 'https' http.verify_mode = OpenSSL::SSL::VERIFY_NONE http end end
invoices()
click to toggle source
# File lib/fs_api/client.rb, line 62 def invoices FsApi::Service::Invoice.new(self) end
invoices_payments()
click to toggle source
# File lib/fs_api/client.rb, line 74 def invoices_payments FsApi::Service::InvoicesPayment.new(self) end
post(path, body=nil, headers={})
click to toggle source
# File lib/fs_api/client.rb, line 49 def post(path, body=nil, headers={}) uri = uri_for_path(path) http = Net::HTTP::Post.new(uri.request_uri, self.headers.merge(headers)) http.body = body perform(http) end
products()
click to toggle source
# File lib/fs_api/client.rb, line 70 def products FsApi::Service::Product.new(self) end
put(path, body=nil, headers={})
click to toggle source
# File lib/fs_api/client.rb, line 42 def put(path, body=nil, headers={}) uri = uri_for_path(path) http = Net::HTTP::Put.new(uri.request_uri, self.headers.merge(headers)) http.body = body perform(http) end
saved_invoices()
click to toggle source
# File lib/fs_api/client.rb, line 78 def saved_invoices FsApi::Service::InvoicesSaved.new(self) end
uri_for_path(path)
click to toggle source
# File lib/fs_api/client.rb, line 32 def uri_for_path(path) URI.parse(File.join(base_url, path)) end
Private Instance Methods
perform(request)
click to toggle source
# File lib/fs_api/client.rb, line 83 def perform(request) request.basic_auth username, password @_last_response = http.request(request) end