Sha256: ddb670e418dbf82c9cc5ff99d5300f86d00f5619753cdf2d11d6755c19912dc3
Contents?: true
Size: 1.99 KB
Versions: 13
Compression:
Stored size: 1.99 KB
Contents
# frozen_string_literal: true module Seam module Clients class AccessCodes < BaseClient def get(access_code_id) request_seam_object( :get, "/access_codes/get", Seam::AccessCode, "access_code", params: {access_code_id: access_code_id} ) end def list(device_or_id) device_id = device_or_id.is_a?(Seam::Device) ? device_or_id.device_id : device_or_id request_seam_object( :get, "/access_codes/list", Seam::AccessCode, "access_codes", params: {device_id: device_id} ) end def create(device_id: nil, name: nil, code: nil, starts_at: nil, ends_at: nil) action_attempt = request_seam_object( :post, "/access_codes/create", Seam::ActionAttempt, "action_attempt", body: {device_id: device_id, code: code, starts_at: starts_at, ends_at: ends_at, name: name}.compact ) action_attempt.wait_until_finished # TODO: check if failed Seam::AccessCode.new(action_attempt.result["access_code"], @client) end def delete(access_code_id) action_attempt = request_seam_object( :post, "/access_codes/delete", Seam::ActionAttempt, "action_attempt", body: {access_code_id: access_code_id} ) action_attempt.wait_until_finished action_attempt end def update(access_code_id: nil, name: nil, code: nil, starts_at: nil, ends_at: nil) action_attempt = request_seam_object( :post, "/access_codes/update", Seam::ActionAttempt, "action_attempt", body: { access_code_id: access_code_id, name: name, code: code, starts_at: starts_at, ends_at: ends_at }.compact ) action_attempt.wait_until_finished action_attempt end end end end
Version data entries
13 entries across 13 versions & 1 rubygems