diff --git a/shard.yml b/shard.yml index 3f80d3f..bd39e3b 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: placeos -version: 2.11.11 +version: 2.12.1 license: MIT description: | diff --git a/src/placeos/api_wrapper/drivers.cr b/src/placeos/api_wrapper/drivers.cr index 12a64d2..76b8014 100644 --- a/src/placeos/api_wrapper/drivers.cr +++ b/src/placeos/api_wrapper/drivers.cr @@ -56,5 +56,17 @@ module PlaceOS ) put "#{base}/#{id}", body: from_args, as: Driver end + + def recompile(id : String) + client.connection do |conn| + url = "#{base}/#{id}/recompile" + response = conn.post(url) + unless response.success? + raise "Recompile failed with status #{response.status_code}: #{response.body}" + end + true + end + end + end end diff --git a/src/placeos/api_wrapper/users.cr b/src/placeos/api_wrapper/users.cr index d838360..fb2b2d1 100644 --- a/src/placeos/api_wrapper/users.cr +++ b/src/placeos/api_wrapper/users.cr @@ -1,9 +1,6 @@ require "./endpoint" module PlaceOS - # TODO: - # - create - # - update class Client::APIWrapper::Users < Client::APIWrapper::Endpoint include Client::APIWrapper::Endpoint::Fetch(User) include Client::APIWrapper::Endpoint::Destroy @@ -18,6 +15,49 @@ module PlaceOS post "#{base}/resource_token", as: ResourceToken end + # Creates a new user. + def create( + email : String, + first_name : String, + last_name : String, + authority_id : String, + password : String? = nil, + confirm_password : String? = nil, + card_number : String? = nil, + groups : Array(String)? = nil, + image : String? = nil, + locatable : Bool? = nil, + staff_id : String? = nil, + support : Bool? = nil, + sys_admin : Bool? = nil, + work_overrides : Hash(String, PlaceOS::Model::User::WorktimePreference)? = nil, + work_preferences : Array(PlaceOS::Model::User::WorktimePreference)? = nil + ) + post base, body: from_args, as: User + end + + # Updates an existing user. + def update( + id : String, + email : String? = nil, + first_name : String? = nil, + last_name : String? = nil, + authority_id : String? = nil, + password : String? = nil, + confirm_password : String? = nil, + card_number : String? = nil, + groups : Array(String)? = nil, + image : String? = nil, + locatable : Bool? = nil, + staff_id : String? = nil, + support : Bool? = nil, + sys_admin : Bool? = nil, + work_overrides : Hash(String, PlaceOS::Model::User::WorktimePreference)? = nil, + work_preferences : Array(PlaceOS::Model::User::WorktimePreference)? = nil + ) + put "#{base}/#{id}", body: from_args, as: User + end + # List or search for users. # # Results maybe filtered by specifying a query - *q* - to search across zone