lib/gooddata/models/membership.rb in gooddata-0.6.24 vs lib/gooddata/models/membership.rb in gooddata-0.6.25
- old
+ new
@@ -11,11 +11,11 @@
require_relative 'project_role'
require_relative '../rest/object'
module GoodData
- class Membership < GoodData::Rest::Object
+ class Membership < Rest::Resource
attr_reader :json
ASSIGNABLE_MEMBERS = [
:email,
:first_name,
@@ -107,11 +107,11 @@
#
# @return [String] Contributor
def contributor
url = @json['user']['meta']['contributor']
data = client.get url
- client.factory.create(GoodData::Membership, data)
+ client.create(GoodData::Membership, data)
end
# Gets date when created
#
# @return [DateTime] Created date
@@ -240,22 +240,22 @@
end
# Gets profile of this membership
def profile
raw = client.get @json['user']['links']['self']
- client.factory.create(GoodData::Profile, raw)
+ client.create(GoodData::Profile, raw)
end
# Gets URL of profile membership
def profile_url
@json['user']['links']['self']
end
# # Gets project which this membership relates to
# def project
# raw = client.get project_url
- # client.factory.create(GoodData::Project, raw)
+ # client.create(GoodData::Project, raw)
# end
# Gets project id
def project_id
@json['user']['links']['roles'].split('/')[3]
@@ -272,11 +272,11 @@
def projects
tmp = client.get @json['user']['links']['projects']
tmp['projects'].map do |project_meta|
project_uri = project_meta['project']['links']['self']
project = client.get project_uri
- client.factory.create(GoodData::Project, project)
+ client.create(GoodData::Project, project)
end
end
# Gets first role
#
@@ -292,11 +292,11 @@
roles_link = GoodData::Helpers.get_path(@json, %w(user links roles))
return unless roles_link
tmp = client.get roles_link
tmp['associatedRoles']['roles'].pmap do |role_uri|
role = client.get role_uri
- client.factory.create(GoodData::ProjectRole, role)
+ client.create(GoodData::ProjectRole, role)
end
end
# Gets the status
#
@@ -397,9 +397,13 @@
wire, rb = vals
tmp[rb] = tmp[wire]
tmp.delete(wire)
end
tmp
+ end
+
+ def user_groups
+ project.user_groups(:all, user: obj_id)
end
private
# Sets status to 'ENABLED' or 'DISABLED'