Module: Restiny::Api::Profile

Includes:
Base
Included in:
Restiny
Defined in:
lib/restiny/api/profile.rb

Instance Method Summary collapse

Methods included from Base

#api_get, #api_post

Instance Method Details

#get_character_profile(character_id:, membership_id:, membership_type:, components:) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/restiny/api/profile.rb', line 22

def get_character_profile(character_id:, membership_id:, membership_type:, components:)
  get_profile(
    membership_id: membership_id,
    membership_type: membership_type,
    components: components,
    type_url: "Character/#{character_id}/"
  )
end

#get_instanced_item_profile(item_id:, membership_id:, membership_type:, components:) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/restiny/api/profile.rb', line 31

def get_instanced_item_profile(item_id:, membership_id:, membership_type:, components:)
  get_profile(
    membership_id: membership_id,
    membership_type: membership_type,
    components: components,
    type_url: "Item/#{item_id}/"
  )
end

#get_profile(membership_id:, membership_type:, components:, type_url: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/restiny/api/profile.rb', line 10

def get_profile(membership_id:, membership_type:, components:, type_url: nil)
  if !components.is_a?(Array) || components.empty?
    raise Restiny::InvalidParamsError, 'Please provide at least one component'
  end

  url = "Destiny2/#{membership_type}/Profile/#{membership_id}/"
  url += type_url if type_url
  url += "?components=#{components.join(',')}"

  api_get(endpoint: url)
end