Class: PlayStationNetworkAPI::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/play_station_network_api/client.rb

Direct Known Subclasses

Catalog, Entitlement, Explore, Game, Search, Trophy, User

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(refresh_token, account_id: 'me', country: 'GB', language: 'en') ⇒ Client

Returns a new instance of Client.



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

def initialize(refresh_token, account_id: 'me', country: 'GB', language: 'en')
  @refresh_token = refresh_token
  @default_headers = {
    # TODO: Make this a variable for other languages
    'Accept-Language' => 'en-US',
    'User-Agent' => "psn-api/#{ VERSION }"
  }

  @account_id = 
  @country = country
  @language = language
end

Instance Attribute Details

#account_idObject

Returns the value of attribute account_id.



10
11
12
# File 'lib/play_station_network_api/client.rb', line 10

def 
  @account_id
end

#ageObject

Returns the value of attribute age.



10
11
12
# File 'lib/play_station_network_api/client.rb', line 10

def age
  @age
end

#countryObject

Returns the value of attribute country.



10
11
12
# File 'lib/play_station_network_api/client.rb', line 10

def country
  @country
end

#default_headersObject

Returns the value of attribute default_headers.



10
11
12
# File 'lib/play_station_network_api/client.rb', line 10

def default_headers
  @default_headers
end

#languageObject

Returns the value of attribute language.



10
11
12
# File 'lib/play_station_network_api/client.rb', line 10

def language
  @language
end

#refresh_tokenObject

Returns the value of attribute refresh_token.



10
11
12
# File 'lib/play_station_network_api/client.rb', line 10

def refresh_token
  @refresh_token
end

Instance Method Details

#catalogObject



27
28
29
30
31
32
33
# File 'lib/play_station_network_api/client.rb', line 27

def catalog
  PlayStationNetworkAPI::Catalog.new(refresh_token, 
    account_id: , 
    country: country, 
    language: language
  )
end

#entitlementObject



35
36
37
38
39
40
41
# File 'lib/play_station_network_api/client.rb', line 35

def entitlement
  PlayStationNetworkAPI::Entitlement.new(refresh_token, 
    account_id: , 
    country: country, 
    language: language
  )
end

#exploreObject



43
44
45
46
47
48
49
# File 'lib/play_station_network_api/client.rb', line 43

def explore
  PlayStationNetworkAPI::Explore.new(refresh_token, 
    account_id: , 
    country: country, 
    language: language
  )
end

#gameObject



51
52
53
54
55
56
57
# File 'lib/play_station_network_api/client.rb', line 51

def game
  PlayStationNetworkAPI::Game.new(refresh_token, 
    account_id: , 
    country: country, 
    language: language
  )
end

#get_account_devicesObject



99
100
101
102
103
104
# File 'lib/play_station_network_api/client.rb', line 99

def 
  self.class.base_uri 'https://dms.api.playstation.com/api'

  # https://dms.api.playstation.com/api/v1/devices/accounts/me
  get('/v1/devices/accounts/me').parsed_response['accountDevices']
end

#get_account_idObject



92
93
94
95
96
97
# File 'lib/play_station_network_api/client.rb', line 92

def 
  self.class.base_uri 'https://dms.api.playstation.com/api'

  # https://dms.api.playstation.com/api/v1/devices/accounts/me
  get('/v1/devices/accounts/me').parsed_response['accountId']
end

#searchObject



59
60
61
62
63
64
65
# File 'lib/play_station_network_api/client.rb', line 59

def search
  PlayStationNetworkAPI::Search.new(refresh_token, 
    account_id: , 
    country: country, 
    language: language
  )
end

#sessionObject



67
68
69
70
71
72
73
# File 'lib/play_station_network_api/client.rb', line 67

def session
  PlayStationNetworkAPI::Session.new(refresh_token, 
    account_id: , 
    country: country, 
    language: language
  )
end

#trophyObject



75
76
77
78
79
80
81
# File 'lib/play_station_network_api/client.rb', line 75

def trophy
  PlayStationNetworkAPI::Trophy.new(refresh_token, 
    account_id: , 
    country: country, 
    language: language
  )
end

#userObject



83
84
85
86
87
88
89
# File 'lib/play_station_network_api/client.rb', line 83

def user
  PlayStationNetworkAPI::User.new(refresh_token, 
    account_id: , 
    country: country, 
    language: language
  )
end