Sha256: 3d96aaaf134fb09c9757c1e6785e48680c8c424da1f65fe1f1599571f476e8ae

Contents?: true

Size: 899 Bytes

Versions: 6

Compression:

Stored size: 899 Bytes

Contents

module ArtemisApi
  class User < ArtemisApi::Model
    json_type 'users'
    related_to_many :facilities

    def self.get_current(client:, include: nil)
      self.json_type
      client.refresh if client.oauth_token.expired?
      url = "#{client.options[:base_uri]}/api/v3/user"
      url = "#{url}?include=#{include}" if include
      response = client.oauth_token.get(url)
      if response.status == 200
        json = JSON.parse(response.body)
        obj = client.store_record('users', json['data']['id'], json['data'])
      end
      obj
    end

    def self.find(id:, facility_id:, client:, include: nil, force: false)
      client.find_one(self.json_type, id, facility_id: facility_id, include: include, force: force)
    end

    def self.find_all(facility_id:, client:, include: nil)
      client.find_all(self.json_type, facility_id: facility_id, include: include)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
artemis_api-0.5.1 lib/artemis_api/user.rb
artemis_api-0.4.0 lib/artemis_api/user.rb
artemis_api-0.3.0 lib/artemis_api/user.rb
artemis_api-0.2.1 lib/artemis_api/user.rb
artemis_api-0.2.0 lib/artemis_api/user.rb
artemis_api-0.1.0 lib/artemis_api/user.rb