Class: Spotted::Client
Constant Summary
collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2
- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0
- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5
- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary
collapse
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(client_id: ENV["SPOTIFY_CLIENT_ID"], client_secret: ENV["SPOTIFY_CLIENT_SECRET"], base_url: ENV["SPOTTED_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
Creates and returns a new client for interacting with the API.
‘“api.example.com/v2/”`. Defaults to `ENV`
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
# File 'lib/spotted/client.rb', line 122
def initialize(
client_id: ENV["SPOTIFY_CLIENT_ID"],
client_secret: ENV["SPOTIFY_CLIENT_SECRET"],
base_url: ENV["SPOTTED_BASE_URL"],
max_retries: self.class::DEFAULT_MAX_RETRIES,
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
)
base_url ||= "https://api.spotify.com/v1"
if client_id.nil?
raise ArgumentError.new("client_id is required, and can be set via environ: \"SPOTIFY_CLIENT_ID\"")
end
if client_secret.nil?
raise ArgumentError.new("client_secret is required, and can be set via environ: \"SPOTIFY_CLIENT_SECRET\"")
end
@client_id = client_id.to_s
@client_secret = client_secret.to_s
super(
base_url: base_url,
timeout: timeout,
max_retries: max_retries,
initial_retry_delay: initial_retry_delay,
max_retry_delay: max_retry_delay
)
@albums = Spotted::Resources::Albums.new(client: self)
@artists = Spotted::Resources::Artists.new(client: self)
@shows = Spotted::Resources::Shows.new(client: self)
@episodes = Spotted::Resources::Episodes.new(client: self)
@audiobooks = Spotted::Resources::Audiobooks.new(client: self)
@me = Spotted::Resources::Me.new(client: self)
@chapters = Spotted::Resources::Chapters.new(client: self)
@tracks = Spotted::Resources::Tracks.new(client: self)
@search = Spotted::Resources::Search.new(client: self)
@playlists = Spotted::Resources::Playlists.new(client: self)
@users = Spotted::Resources::Users.new(client: self)
@browse = Spotted::Resources::Browse.new(client: self)
@audio_features = Spotted::Resources::AudioFeatures.new(client: self)
@audio_analysis = Spotted::Resources::AudioAnalysis.new(client: self)
@recommendations = Spotted::Resources::Recommendations.new(client: self)
@webhooks = Spotted::Resources::Webhooks.new(client: self)
@markets = Spotted::Resources::Markets.new(client: self)
end
|
Instance Attribute Details
25
26
27
|
# File 'lib/spotted/client.rb', line 25
def albums
@albums
end
|
28
29
30
|
# File 'lib/spotted/client.rb', line 28
def artists
@artists
end
|
64
65
66
|
# File 'lib/spotted/client.rb', line 64
def audio_analysis
@audio_analysis
end
|
61
62
63
|
# File 'lib/spotted/client.rb', line 61
def audio_features
@audio_features
end
|
37
38
39
|
# File 'lib/spotted/client.rb', line 37
def audiobooks
@audiobooks
end
|
58
59
60
|
# File 'lib/spotted/client.rb', line 58
def browse
@browse
end
|
43
44
45
|
# File 'lib/spotted/client.rb', line 43
def chapters
@chapters
end
|
#client_id ⇒ String
19
20
21
|
# File 'lib/spotted/client.rb', line 19
def client_id
@client_id
end
|
#client_secret ⇒ String
22
23
24
|
# File 'lib/spotted/client.rb', line 22
def client_secret
@client_secret
end
|
34
35
36
|
# File 'lib/spotted/client.rb', line 34
def episodes
@episodes
end
|
73
74
75
|
# File 'lib/spotted/client.rb', line 73
def markets
@markets
end
|
40
41
42
|
# File 'lib/spotted/client.rb', line 40
def me
@me
end
|
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
77
78
79
|
# File 'lib/spotted/client.rb', line 77
def oauth_2_0_state
@oauth_2_0_state
end
|
52
53
54
|
# File 'lib/spotted/client.rb', line 52
def playlists
@playlists
end
|
67
68
69
|
# File 'lib/spotted/client.rb', line 67
def recommendations
@recommendations
end
|
49
50
51
|
# File 'lib/spotted/client.rb', line 49
def search
@search
end
|
31
32
33
|
# File 'lib/spotted/client.rb', line 31
def shows
@shows
end
|
46
47
48
|
# File 'lib/spotted/client.rb', line 46
def tracks
@tracks
end
|
55
56
57
|
# File 'lib/spotted/client.rb', line 55
def users
@users
end
|
70
71
72
|
# File 'lib/spotted/client.rb', line 70
def webhooks
@webhooks
end
|