Class: PlayStationNetworkAPI::Trophy
- Defined in:
- lib/play_station_network_api/trophy.rb
Instance Attribute Summary
Attributes inherited from Client
#account_id, #age, #country, #default_headers, #language, #refresh_token
Instance Method Summary collapse
-
#get_communication_id(title_ids = []) ⇒ Object
title_ids Array[].
-
#summary ⇒ Object
TODO: Test against PS5 titles, using ‘trophy2’ as the npServiceName.
-
#titles(title_ids = [], offset: 0, limit: 10) ⇒ Object
title_ids [Array] offset [Integer] limit [Integer] { min: 1, max: 1000 }.
-
#trophies(communication_id, trophy_group_id = nil) ⇒ Object
communication_id [String] trophy_group_id [String | Integer] => ‘default’, ‘001’, 002.
-
#trophy_details(communication_id, trophy_id) ⇒ Object
communication_id [String] trophy_id [Integer].
-
#trophy_groups(communication_id) ⇒ Object
communication_id [String].
Methods inherited from Client
#catalog, #entitlement, #explore, #game, #get_account_devices, #get_account_id, #initialize, #search, #session, #trophy, #user
Constructor Details
This class inherits a constructor from PlayStationNetworkAPI::Client
Instance Method Details
#get_communication_id(title_ids = []) ⇒ Object
title_ids Array[]
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/play_station_network_api/trophy.rb', line 90 def get_communication_id(title_ids = []) # https://gb-tpy.np.community.playstation.net/trophy/v1/apps/trophyTitles?npTitleIds=CUSA15010_00,CUSA20046_00,CUSA24894_00,CUSA24269_00,CUSA24267_00 get('/trophy/v1/apps/trophyTitles', base_uri: 'https://gb-tpy.np.community.playstation.net', query: { npTitleIds: title_ids.join(',') }, ).parsed_response end |
#summary ⇒ Object
TODO: Test against PS5 titles, using ‘trophy2’ as the npServiceName
5 6 7 8 |
# File 'lib/play_station_network_api/trophy.rb', line 5 def summary # https://m.np.playstation.net/api/trophy/v1/users/6462910331343535058/trophySummary get([path, 'trophySummary'].join('/')).parsed_response end |
#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 |
#trophies(communication_id, trophy_group_id = nil) ⇒ Object
communication_id [String] trophy_group_id [String | Integer] => ‘default’, ‘001’, 002
61 62 63 64 65 66 67 68 69 |
# File 'lib/play_station_network_api/trophy.rb', line 61 def trophies(communication_id, trophy_group_id = nil) # BROKEN: https://m.np.playstation.net/api/trophy/v1/users/6462910331343535058/npCommunicationIds/NPWR00133_00/trophies?npServiceName=trophy # https://m.np.playstation.net/api/trophy/v1/users/6462910331343535058/npCommunicationIds/NPWR00133_00/trophyGroups/default/trophies?npServiceName=trophy get([path, 'npCommunicationIds', communication_id, 'trophyGroups', ([trophy_group_id, 'trophies'] if trophy_group_id)].flatten.compact.join('/'), query: { npServiceName: 'trophy' } ).parsed_response end |
#trophy_details(communication_id, trophy_id) ⇒ Object
communication_id [String] trophy_id [Integer]
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/play_station_network_api/trophy.rb', line 73 def trophy_details(communication_id, trophy_id) url = if account_id # https://m.np.playstation.net/api/trophy/v1/npCommunicationIds/NPWR00133_00/trophies/2?npServiceName=trophy [path, 'npCommunicationIds', communication_id, 'trophies', trophy_id] else # https://m.np.playstation.net/api/trophy/v1/users/6462910331343535058/npCommunicationIds/NPWR00133_00/trophies/2?npServiceName=trophy [path(communication_id), 'trophies', trophy_id] end get(url.join('/'), query: { npServiceName: 'trophy' } ).parsed_response end |
#trophy_groups(communication_id) ⇒ Object
communication_id [String]
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/play_station_network_api/trophy.rb', line 43 def trophy_groups(communication_id) url = if account_id # https://m.np.playstation.net/api/trophy/v1/users/6462910331343535058/npCommunicationIds/NPWR00133_00/trophyGroups?npServiceName=trophy [path, 'npCommunicationIds', communication_id, 'trophyGroups'] else # https://m.np.playstation.net/api/trophy/v1/npCommunicationIds/NPWR00133_00/trophyGroups?npServiceName=trophy [path(communication_id), 'trophyGroups'] end get(url.join('/'), query: { npServiceName: 'trophy' } ).parsed_response end |