Compare commits
4 Commits
027b125285
...
f0846308da
Author | SHA1 | Date | |
---|---|---|---|
f0846308da | |||
b3b7fe6359 | |||
f0b541ee50 | |||
df9077e3c1 |
@ -4,19 +4,19 @@
|
|||||||
class BtcpayManagerService < RestApiService
|
class BtcpayManagerService < RestApiService
|
||||||
private
|
private
|
||||||
|
|
||||||
def base_url
|
def base_url
|
||||||
@base_url ||= "#{Setting.btcpay_api_url}/stores/#{Setting.btcpay_store_id}"
|
@base_url ||= "#{Setting.btcpay_api_url}/stores/#{Setting.btcpay_store_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def auth_token
|
def auth_token
|
||||||
@auth_token ||= Setting.btcpay_auth_token
|
@auth_token ||= Setting.btcpay_auth_token
|
||||||
end
|
end
|
||||||
|
|
||||||
def headers
|
def headers
|
||||||
{
|
{
|
||||||
"Content-Type" => "application/json",
|
"Content-Type" => "application/json",
|
||||||
"Accept" => "application/json",
|
"Accept" => "application/json",
|
||||||
"Authorization" => "token #{auth_token}"
|
"Authorization" => "token #{auth_token}"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,19 +4,19 @@
|
|||||||
class MastodonManagerService < RestApiService
|
class MastodonManagerService < RestApiService
|
||||||
private
|
private
|
||||||
|
|
||||||
def base_url
|
def base_url
|
||||||
@base_url ||= "#{Setting.mastodon_public_url}/api"
|
@base_url ||= "#{Setting.mastodon_public_url}/api"
|
||||||
end
|
end
|
||||||
|
|
||||||
def auth_token
|
def auth_token
|
||||||
@auth_token ||= Setting.mastodon_auth_token
|
@auth_token ||= Setting.mastodon_auth_token
|
||||||
end
|
end
|
||||||
|
|
||||||
def headers
|
def headers
|
||||||
{
|
{
|
||||||
"Content-Type" => "application/json",
|
"Content-Type" => "application/json",
|
||||||
"Accept" => "application/json",
|
"Accept" => "application/json",
|
||||||
"Authorization" => "Bearer #{auth_token}"
|
"Authorization" => "Bearer #{auth_token}"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
class RestApiService < ApplicationService
|
class RestApiService < ApplicationService
|
||||||
private
|
private
|
||||||
|
|
||||||
def base_url
|
def base_url
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
def headers
|
def headers
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
def endpoint_url(path)
|
def endpoint_url(path)
|
||||||
"#{base_url}/#{path.gsub(/^\//, '')}"
|
"#{base_url}/#{path.gsub(/^\//, '')}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(path, params = {})
|
def get(path, params = {})
|
||||||
res = Faraday.get endpoint_url(path), params, headers
|
res = Faraday.get endpoint_url(path), params, headers
|
||||||
# TODO handle unsuccessful responses with no valid JSON body
|
# TODO handle unsuccessful responses with no valid JSON body
|
||||||
JSON.parse(res.body)
|
JSON.parse(res.body)
|
||||||
end
|
end
|
||||||
|
|
||||||
def post(path, payload)
|
def post(path, payload)
|
||||||
res = Faraday.post endpoint_url(path), payload.to_json, headers
|
res = Faraday.post endpoint_url(path), payload.to_json, headers
|
||||||
# TODO handle unsuccessful responses with no valid JSON body
|
# TODO handle unsuccessful responses with no valid JSON body
|
||||||
JSON.parse(res.body)
|
JSON.parse(res.body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,6 +11,8 @@ module UserManager
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
def import_remote_avatar
|
def import_remote_avatar
|
||||||
tempfile = Down.download(@avatar_url)
|
tempfile = Down.download(@avatar_url)
|
||||||
content_type = tempfile.content_type
|
content_type = tempfile.content_type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user