Method: PlayStationNetworkAPI::Trophy#titles

Defined in:
lib/play_station_network_api/trophy.rb

#titles(title_ids = [], offset: 0, limit: 10) ⇒ Object

title_ids [Array] offset [Integer] limit [Integer]

min: 1,
max: 1000



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/play_station_network_api/trophy.rb', line 16

def titles(title_ids = [], offset: 0, limit: 10)
  raise 'title_ids size must be less than or equal to 5' if title_ids.length > 5
  raise 'limit must be less than or equal to 5000' if limit > 5000

  if title_ids.empty?
    # https://m.np.playstation.net/api/trophy/v1/users/6462910331343535058/trophyTitles
    get([path, 'trophyTitles'].join('/'),
      query: {
        offset: offset,
        limit: limit
      }
    ).parsed_response
    
    # TODO: Cast every response to a Model
    # return PlayStationNetworkAPI::Models::Trophy.new(request.parsed_response)
  else
    # https://m.np.playstation.net/api/trophy/v1/users/6462910331343535058/titles/trophyTitles?npTitleIds=CUSA00054_00,CUSA07970_00,CUSA00208_00,CUSA00938_00,CUSA01985_00

    get([path, 'titles', 'trophyTitles'].join('/'),
      query: {
        npTitleIds: title_ids.join(',')
      }
    ).parsed_response
  end
end