Class: PowerBI::UserArray

Inherits:
Array
  • Object
show all
Defined in:
lib/power-bi/user.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Array

#reload

Constructor Details

#initialize(tenant, workspace) ⇒ UserArray

Returns a new instance of UserArray.



29
30
31
32
# File 'lib/power-bi/user.rb', line 29

def initialize(tenant, workspace)
  super(tenant, workspace)
  @workspace = workspace
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PowerBI::Array

Class Method Details

.get_classObject



34
35
36
# File 'lib/power-bi/user.rb', line 34

def self.get_class
  User
end

Instance Method Details

#create(email_address, access_right: "Viewer") ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/power-bi/user.rb', line 38

def create(email_address, access_right: "Viewer")
  @tenant.post("/groups/#{@workspace.id}/users") do |req|
    req.body = {
      emailAddress: email_address,
      groupUserAccessRight: access_right
    }.to_json
  end
  self.reload
end

#get_dataObject



48
49
50
# File 'lib/power-bi/user.rb', line 48

def get_data
  @tenant.get("/groups/#{@workspace.id}/users")[:value]
end