Class: PlayStationNetworkAPI::Catalog

Inherits:
Client
  • Object
show all
Defined in:
lib/play_station_network_api/catalog.rb

Instance Attribute Summary

Attributes inherited from Client

#account_id, #age, #country, #default_headers, #language, #refresh_token

Instance Method Summary collapse

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

#concept(concept_id, metadata: false) ⇒ Object

concept_id [Integer] metadata [Boolean]: Different data is returned when true; stuff like age restrictions, release dates in different countries etc..



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/play_station_network_api/catalog.rb', line 27

def concept(concept_id, metadata: false)
  options = {}

  if 
    options[:query] = {
      country: country,
      language: language,
      age: 999
    }
  end

  # https://m.np.playstation.net/api/catalog/v2/concepts/10000470
  # https://m.np.playstation.net/api/catalog/v2/concepts/10000470?country=GB&language=en&age=999
  get([path, 'concepts', concept_id].join('/'), options).parsed_response
end

#most_purchased(offset: 0, limit: 10) ⇒ Object

offset [Integer] limit [Integer]

min: 1,
max: 1000



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/play_station_network_api/catalog.rb', line 9

def most_purchased(offset: 0, limit: 10)
  raise 'limit must be less than or equal to 1000' if limit > 1000
  warn "[DEPRECATED] This endpoint has been marked as deprecated on the PlayStation API, don't rely on it as things might break in the future!"

  # https://m.np.playstation.net/api/catalog/v2/concepts/fetch?country=GB&language=en&age=999&limit=1000&offset=1
  get([path, 'concepts', 'fetch'].join('/'),
    query: {
      country: country,
      language: language,
      age: 999,
      limit: limit,
      offset: offset
    }
  ).parsed_response
end

#products(concept_id, offset: 0, limit: 10) ⇒ Object

concept_id [Integer] offset [Integer] limit [Integer]

min: 1,
max: 1000



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/play_station_network_api/catalog.rb', line 49

def products(concept_id, offset: 0, limit: 10)
  raise 'limit must be less than or equal to 1000' if limit > 1000
  
  # https://m.np.playstation.net/api/catalog/v2/concepts/10000470/products?country=GB&language=en&age=999&limit=1000
  get([path, 'concepts', concept_id, 'products'].join('/'),
    query: {
      country: country,
      language: language,
      age: age,
      limit: limit,
      offset: offset
    }
  ).parsed_response
end

#title(title_id) ⇒ Object

title_id [String]



75
76
77
78
# File 'lib/play_station_network_api/catalog.rb', line 75

def title(title_id)
  # https://m.np.playstation.net/api/catalog/v2/titles/CUSA18182_00/?country=GB&language=en&age=999
  get([path, 'title', title_id].join('/')).parsed_response
end

#title_age_limit(title_id) ⇒ Object

title_id [String]



81
82
83
# File 'lib/play_station_network_api/catalog.rb', line 81

def title_age_limit(title_id)
  get([path, 'title', title_id, 'ageLimit'].join('/')).parsed_response
end

#title_ids_to_concept_id(title_ids) ⇒ Object

title_ids [Array]



65
66
67
68
69
70
71
72
# File 'lib/play_station_network_api/catalog.rb', line 65

def title_ids_to_concept_id(title_ids)
  raise 'limit must be less than or equal to 500' if title_ids.length > 500

  # https://m.np.playstation.net/api/catalog/v2/titles/[..]/concepts/id
  response = get([path, 'titles', title_ids, 'concepts', 'id'].join('/')).parsed_response
  
  return title_ids.length == 1 ? response[0] : response
end