class PowerBiEmbedded::Authenticate

Constants

BASE_URL
RESOURCE

Public Class Methods

new(username: nil, password: nil, refresh_token: nil, client_id: nil, grant_type: nil) click to toggle source
# File lib/power_bi_embedded/authenticate.rb, line 7
def initialize(username: nil, password: nil, refresh_token: nil, client_id: nil, grant_type: nil)
  @username      = username
  @password      = password
  @refresh_token = refresh_token
  @client_id     = client_id
  @grant_type    = grant_type
end

Public Instance Methods

call() click to toggle source
# File lib/power_bi_embedded/authenticate.rb, line 15
def call
  PowerBiEmbedded::Base.post(BASE_URL, build_body, build_headers)
end

Private Instance Methods

build_body() click to toggle source
# File lib/power_bi_embedded/authenticate.rb, line 21
def build_body
  {
    client_id: @client_id,
    grant_type: @grant_type,
    resource: RESOURCE,
    username: @username,
    password: @password,
    refresh_token: @refresh_token
  }.compact
end
build_headers() click to toggle source
# File lib/power_bi_embedded/authenticate.rb, line 32
def build_headers
  { 'Content-Type': 'application/x-www-form-urlencoded'}
end