Sha256: f7c0662e7f21e4bfdfafc02a650f4d68effc03b62f1b5d3caeac4849dd54bbe9

Contents?: true

Size: 1.22 KB

Versions: 18

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true
require 'dato/site/repo/base'

module Dato
  module Site
    module Repo
      class AccessToken < Base
        def create(resource_attributes)
          body = JsonApiSerializer.new(
            type: :access_token,
            attributes: %i(name),
            relationships: { role: { collection: false, type: :role } },
            required_attributes: %i(name)
          ).serialize(resource_attributes)

          post_request '/access_tokens', body
        end

        def update(user_id, resource_attributes)
          body = JsonApiSerializer.new(
            type: :access_token,
            attributes: %i(name),
            relationships: { role: { collection: false, type: :role } }
          ).serialize(resource_attributes, user_id)

          put_request "/access_tokens/#{user_id}", body
        end

        def all
          get_request '/access_tokens'
        end

        def find(user_id)
          get_request "/access_tokens/#{user_id}"
        end

        def regenerate_token(user_id)
          post_request "/access_tokens/#{user_id}/regenerate_token"
        end

        def destroy(user_id)
          delete_request "/access_tokens/#{user_id}"
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
dato-0.5.1 lib/dato/site/repo/access_token.rb
dato-0.5.0 lib/dato/site/repo/access_token.rb
dato-0.4.3 lib/dato/site/repo/access_token.rb
dato-0.4.2 lib/dato/site/repo/access_token.rb
dato-0.4.1 lib/dato/site/repo/access_token.rb
dato-0.4.0 lib/dato/site/repo/access_token.rb
dato-0.3.31 lib/dato/site/repo/access_token.rb
dato-0.4.0.pre lib/dato/site/repo/access_token.rb
dato-0.3.30 lib/dato/site/repo/access_token.rb
dato-0.3.29 lib/dato/site/repo/access_token.rb
dato-0.3.28 lib/dato/site/repo/access_token.rb
dato-0.3.27 lib/dato/site/repo/access_token.rb
dato-0.3.26 lib/dato/site/repo/access_token.rb
dato-0.3.25 lib/dato/site/repo/access_token.rb
dato-0.3.24 lib/dato/site/repo/access_token.rb
dato-0.3.23 lib/dato/site/repo/access_token.rb
dato-0.3.22 lib/dato/site/repo/access_token.rb
dato-0.3.21 lib/dato/site/repo/access_token.rb