From 1cd8a92d4dab0255279ffca414f700190977b32d Mon Sep 17 00:00:00 2001 From: Kevin Soltysiak Date: Sun, 11 Feb 2024 17:43:06 +0100 Subject: [PATCH] refactor: remove unpack from API calls --- lib/scalingo/auth/keys.rb | 17 +++------- lib/scalingo/auth/scm_integrations.rb | 16 +++------ lib/scalingo/auth/tokens.rb | 20 +++--------- lib/scalingo/auth/two_factor_auth.rb | 16 +++------ lib/scalingo/auth/user.rb | 12 ++----- lib/scalingo/billing/profile.rb | 12 ++----- lib/scalingo/core_client.rb | 2 +- lib/scalingo/regional/addons.rb | 36 ++++++--------------- lib/scalingo/regional/apps.rb | 32 +++++------------- lib/scalingo/regional/autoscalers.rb | 20 +++--------- lib/scalingo/regional/collaborators.rb | 16 +++------ lib/scalingo/regional/containers.rb | 16 +++------ lib/scalingo/regional/deployments.rb | 12 ++----- lib/scalingo/regional/domains.rb | 20 +++--------- lib/scalingo/regional/environment.rb | 24 ++++---------- lib/scalingo/regional/events.rb | 16 +++------ lib/scalingo/regional/logs.rb | 8 ++--- lib/scalingo/regional/metrics.rb | 8 ++--- lib/scalingo/regional/notifiers.rb | 28 ++++------------ lib/scalingo/regional/operations.rb | 4 +-- lib/scalingo/regional/scm_repo_links.rb | 32 +++++------------- lib/scalingo/regional_database/backups.rb | 12 ++----- lib/scalingo/regional_database/databases.rb | 8 ++--- 23 files changed, 98 insertions(+), 289 deletions(-) diff --git a/lib/scalingo/auth/keys.rb b/lib/scalingo/auth/keys.rb index ef917c4..64f6449 100644 --- a/lib/scalingo/auth/keys.rb +++ b/lib/scalingo/auth/keys.rb @@ -5,52 +5,45 @@ class Auth::Keys < API::Endpoint def all(headers = nil, &block) data = nil - response = connection.get( + connection.get( "keys", data, headers, &block ) - - unpack(:keys) { response } end def show(id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "keys/#{id}", data, headers, &block ) - - unpack(:key) { response } end def create(payload, headers = nil, &block) data = {key: payload} - response = connection.post( + connection.post( "keys", data, headers, &block ) - - unpack(:key) { response } end def destroy(id, headers = nil, &block) data = nil - response = connection.delete( + + connection.delete( "keys/#{id}", data, headers, &block ) - - unpack { response } end end end diff --git a/lib/scalingo/auth/scm_integrations.rb b/lib/scalingo/auth/scm_integrations.rb index 1755bc6..224aa85 100644 --- a/lib/scalingo/auth/scm_integrations.rb +++ b/lib/scalingo/auth/scm_integrations.rb @@ -5,53 +5,45 @@ class Auth::ScmIntegrations < API::Endpoint def all(headers = nil, &block) data = nil - response = connection.get( + connection.get( "scm_integrations", data, headers, &block ) - - unpack(:scm_integrations) { response } end def show(id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "scm_integrations/#{id}", data, headers, &block ) - - unpack(:scm_integration) { response } end def create(payload, headers = nil, &block) data = {scm_integration: payload} - response = connection.post( + connection.post( "scm_integrations", data, headers, &block ) - - unpack(:scm_integration) { response } end def destroy(id, headers = nil, &block) data = nil - response = connection.delete( + connection.delete( "scm_integrations/#{id}", data, headers, &block ) - - unpack { response } end end end diff --git a/lib/scalingo/auth/tokens.rb b/lib/scalingo/auth/tokens.rb index 6d1167f..f3cc5a0 100644 --- a/lib/scalingo/auth/tokens.rb +++ b/lib/scalingo/auth/tokens.rb @@ -13,66 +13,56 @@ def exchange(token, headers = nil, &block) request_headers.update(headers) if headers - response = client.unauthenticated_connection.post( + client.unauthenticated_connection.post( "tokens/exchange", data, request_headers, &block ) - - unpack { response } end def all(headers = nil, &block) data = nil - response = connection.get( + connection.get( "tokens", data, headers, &block ) - - unpack(:tokens) { response } end def create(payload, headers = nil, &block) data = {token: payload} - response = connection.post( + connection.post( "tokens", data, headers, &block ) - - unpack(:token) { response } end def renew(id, headers = nil, &block) data = nil - response = connection.patch( + connection.patch( "tokens/#{id}/renew", data, headers, &block ) - - unpack(:token) { response } end def destroy(id, headers = nil, &block) data = nil - response = connection.delete( + connection.delete( "tokens/#{id}", data, headers, &block ) - - unpack { response } end end end diff --git a/lib/scalingo/auth/two_factor_auth.rb b/lib/scalingo/auth/two_factor_auth.rb index f244e65..ae5e7b3 100644 --- a/lib/scalingo/auth/two_factor_auth.rb +++ b/lib/scalingo/auth/two_factor_auth.rb @@ -9,53 +9,45 @@ class Auth::TwoFactorAuth < API::Endpoint def status(headers = nil, &block) data = nil - response = connection.get( + connection.get( "client/tfa", data, headers, &block ) - - unpack(:tfa) { response } end def initiate(provider = DEFAULT_PROVIDER, headers = nil, &block) data = {tfa: {provider: provider}} - response = connection.post( + connection.post( "client/tfa", data, headers, &block ) - - unpack(:tfa) { response } end def validate(attempt, headers = nil, &block) data = {tfa: {attempt: attempt}} - response = connection.post( + connection.post( "client/tfa/validate", data, headers, &block ) - - unpack(:tfa) { response } end def disable(headers = nil, &block) data = nil - response = connection.delete( + connection.delete( "client/tfa", data, headers, &block ) - - unpack(:tfa) { response } end end end diff --git a/lib/scalingo/auth/user.rb b/lib/scalingo/auth/user.rb index 0498002..7557788 100644 --- a/lib/scalingo/auth/user.rb +++ b/lib/scalingo/auth/user.rb @@ -5,40 +5,34 @@ class Auth::User < API::Endpoint def self(headers = nil, &block) data = nil - response = connection.get( + connection.get( "users/self", data, headers, &block ) - - unpack(:user) { response } end def update(payload, headers = nil, &block) data = {user: payload} - response = connection.put( + connection.put( "users/account", data, headers, &block ) - - unpack(:user) { response } end def stop_free_trial(headers = nil, &block) data = nil - response = connection.post( + connection.post( "users/stop_free_trial", data, headers, &block ) - - unpack { response } end end end diff --git a/lib/scalingo/billing/profile.rb b/lib/scalingo/billing/profile.rb index d7f1a6a..362f3ba 100644 --- a/lib/scalingo/billing/profile.rb +++ b/lib/scalingo/billing/profile.rb @@ -5,40 +5,34 @@ class Billing::Profile < API::Endpoint def show(headers = nil, &block) data = nil - response = connection.get( + connection.get( "profile", data, headers, &block ) - - unpack(:profile) { response } end def create(payload = {}, headers = nil, &block) data = {profile: payload} - response = connection.post( + connection.post( "profiles", data, headers, &block ) - - unpack(:profile) { response } end def update(id, payload = {}, headers = nil, &block) data = {profile: payload} - response = connection.put( + connection.put( "profiles/#{id}", data, headers, &block ) - - unpack(:profile) { response } end alias_method :self, :show diff --git a/lib/scalingo/core_client.rb b/lib/scalingo/core_client.rb index 21c655c..d4c1c76 100644 --- a/lib/scalingo/core_client.rb +++ b/lib/scalingo/core_client.rb @@ -64,7 +64,7 @@ def authenticate_with(access_token: nil, bearer_token: nil, expires_at: nil) if response.successful? self.token = BearerToken.new( - response.data[:token], + response.data, expires_at: expiration, raise_on_expired: config.raise_on_expired_token ) diff --git a/lib/scalingo/regional/addons.rb b/lib/scalingo/regional/addons.rb index ac9967d..aceef10 100644 --- a/lib/scalingo/regional/addons.rb +++ b/lib/scalingo/regional/addons.rb @@ -5,79 +5,67 @@ class Regional::Addons < API::Endpoint def for(app_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/addons", data, headers, &block ) - - unpack(:addons) { response } end def find(app_id, addon_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/addons/#{addon_id}", data, headers, &block ) - - unpack(:addon) { response } end def provision(app_id, payload = {}, headers = nil, &block) data = {addon: payload} - response = connection.post( + connection.post( "apps/#{app_id}/addons", data, headers, &block ) - - unpack(:addon) { response } end def update(app_id, addon_id, payload = {}, headers = nil, &block) data = {addon: payload} - response = connection.patch( + connection.patch( "apps/#{app_id}/addons/#{addon_id}", data, headers, &block ) - - unpack(:addon) { response } end def destroy(app_id, addon_id, headers = nil, &block) data = nil - response = connection.delete( + connection.delete( "apps/#{app_id}/addons/#{addon_id}", data, headers, &block ) - - unpack { response } end def sso(app_id, addon_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/addons/#{addon_id}/sso", data, headers, &block ) - - unpack(:addon) { response } end def authenticate!(app_id, addon_id, headers = nil, &block) @@ -98,40 +86,34 @@ def authenticate!(app_id, addon_id, headers = nil, &block) def token(app_id, addon_id, headers = nil, &block) data = nil - response = connection.post( + connection.post( "apps/#{app_id}/addons/#{addon_id}/token", data, headers, &block ) - - unpack(:addon) { response } end def categories(headers = nil, &block) data = nil - response = connection(fallback_to_guest: true).get( + connection(fallback_to_guest: true).get( "addon_categories", data, headers, &block ) - - unpack(:addon_categories) { response } end def providers(headers = nil, &block) data = nil - response = connection(fallback_to_guest: true).get( + connection(fallback_to_guest: true).get( "addon_providers", data, headers, &block ) - - unpack(:addon_providers) { response } end end end diff --git a/lib/scalingo/regional/apps.rb b/lib/scalingo/regional/apps.rb index 5f615eb..bae29bd 100644 --- a/lib/scalingo/regional/apps.rb +++ b/lib/scalingo/regional/apps.rb @@ -5,27 +5,23 @@ class Regional::Apps < API::Endpoint def all(headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps", data, headers, &block ) - - unpack(:apps) { response } end def find(id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{id}", data, headers, &block ) - - unpack(:app) { response } end def create(payload = {}, headers = nil, &block) @@ -37,73 +33,61 @@ def create(payload = {}, headers = nil, &block) request_headers["X-Dry-Run"] = "true" if dry_run request_headers.update(headers) if headers - response = connection.post( + connection.post( "apps", data, request_headers, &block ) - - unpack(:app) { response } end def update(id, payload = {}, headers = nil, &block) data = {app: payload} - response = connection.patch( + connection.patch( "apps/#{id}", data, headers, &block ) - - unpack(:app) { response } end def logs_url(id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{id}/logs", data, headers, &block ) - - unpack(:logs_url) { response } end def destroy(id, payload = {}, headers = nil, &block) - response = connection.delete( + connection.delete( "apps/#{id}", payload, headers, &block ) - - unpack { response } end def rename(id, payload = {}, headers = nil, &block) - response = connection.post( + connection.post( "apps/#{id}/rename", payload, headers, &block ) - - unpack(:app) { response } end def transfer(id, payload = {}, headers = nil, &block) - response = connection.patch( + connection.patch( "apps/#{id}", payload, headers, &block ) - - unpack(:app) { response } end end end diff --git a/lib/scalingo/regional/autoscalers.rb b/lib/scalingo/regional/autoscalers.rb index 2270430..046c338 100644 --- a/lib/scalingo/regional/autoscalers.rb +++ b/lib/scalingo/regional/autoscalers.rb @@ -5,66 +5,56 @@ class Regional::Autoscalers < API::Endpoint def for(app_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/autoscalers", data, headers, &block ) - - unpack(:autoscalers) { response } end def find(app_id, autoscaler_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/autoscalers/#{autoscaler_id}", data, headers, &block ) - - unpack(:autoscaler) { response } end def create(app_id, payload = {}, headers = nil, &block) data = {autoscaler: payload} - response = connection.post( + connection.post( "apps/#{app_id}/autoscalers", data, headers, &block ) - - unpack(:autoscaler) { response } end def update(app_id, autoscaler_id, payload = {}, headers = nil, &block) data = {autoscaler: payload} - response = connection.patch( + connection.patch( "apps/#{app_id}/autoscalers/#{autoscaler_id}", data, headers, &block ) - - unpack(:autoscaler) { response } end def destroy(app_id, autoscaler_id, headers = nil, &block) data = nil - response = connection.delete( + connection.delete( "apps/#{app_id}/autoscalers/#{autoscaler_id}", data, headers, &block ) - - unpack { response } end end end diff --git a/lib/scalingo/regional/collaborators.rb b/lib/scalingo/regional/collaborators.rb index dc901b4..92307f0 100644 --- a/lib/scalingo/regional/collaborators.rb +++ b/lib/scalingo/regional/collaborators.rb @@ -5,53 +5,45 @@ class Regional::Collaborators < API::Endpoint def for(app_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/collaborators", data, headers, &block ) - - unpack(:collaborators) { response } end def destroy(app_id, collaborator_id, headers = nil, &block) data = nil - response = connection.delete( + connection.delete( "apps/#{app_id}/collaborators/#{collaborator_id}", data, headers, &block ) - - unpack { response } end def invite(app_id, payload = {}, headers = nil, &block) data = {collaborator: payload} - response = connection.post( + connection.post( "apps/#{app_id}/collaborators", data, headers, &block ) - - unpack(:collaborator) { response } end def accept(token, headers = nil, &block) data = {token: token} - response = connection.get( + connection.get( "apps/collaboration", data, headers, &block ) - - unpack { response } end end end diff --git a/lib/scalingo/regional/containers.rb b/lib/scalingo/regional/containers.rb index 446a177..f1e1954 100644 --- a/lib/scalingo/regional/containers.rb +++ b/lib/scalingo/regional/containers.rb @@ -5,53 +5,45 @@ class Regional::Containers < API::Endpoint def for(app_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/containers", data, headers, &block ) - - unpack(:containers) { response } end def scale(app_id, formation, headers = nil, &block) data = {containers: formation} - response = connection.post( + connection.post( "apps/#{app_id}/scale", data, headers, &block ) - - unpack(:containers) { response } end def restart(app_id, scope = [], headers = nil, &block) data = {scope: scope} - response = connection.post( + connection.post( "apps/#{app_id}/restart", data, headers, &block ) - - unpack { response } end def sizes(headers = nil, &block) data = nil - response = connection(fallback_to_guest: true).get( + connection(fallback_to_guest: true).get( "features/container_sizes", data, headers, &block ) - - unpack(:container_sizes) { response } end end end diff --git a/lib/scalingo/regional/deployments.rb b/lib/scalingo/regional/deployments.rb index 407a068..6605585 100644 --- a/lib/scalingo/regional/deployments.rb +++ b/lib/scalingo/regional/deployments.rb @@ -5,40 +5,34 @@ class Regional::Deployments < API::Endpoint def for(app_id, payload = {}, headers = nil, &block) data = payload.compact - response = connection.get( + connection.get( "apps/#{app_id}/deployments", data, headers, &block ) - - unpack(:deployments) { response } end def find(app_id, deployment_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/deployments/#{deployment_id}", data, headers, &block ) - - unpack(:deployment) { response } end def logs(app_id, deployment_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/deployments/#{deployment_id}/output", data, headers, &block ) - - unpack(:deployment) { response } end end end diff --git a/lib/scalingo/regional/domains.rb b/lib/scalingo/regional/domains.rb index 64f84ca..c97d660 100644 --- a/lib/scalingo/regional/domains.rb +++ b/lib/scalingo/regional/domains.rb @@ -5,66 +5,56 @@ class Regional::Domains < API::Endpoint def for(app_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/domains", data, headers, &block ) - - unpack(:domains) { response } end def find(app_id, domain_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/domains/#{domain_id}", data, headers, &block ) - - unpack(:domain) { response } end def create(app_id, payload = {}, headers = nil, &block) data = {domain: payload} - response = connection.post( + connection.post( "apps/#{app_id}/domains", data, headers, &block ) - - unpack(:domain) { response } end def update(app_id, domain_id, payload = {}, headers = nil, &block) data = {domain: payload} - response = connection.patch( + connection.patch( "apps/#{app_id}/domains/#{domain_id}", data, headers, &block ) - - unpack(:domain) { response } end def destroy(app_id, domain_id, headers = nil, &block) data = nil - response = connection.delete( + connection.delete( "apps/#{app_id}/domains/#{domain_id}", data, headers, &block ) - - unpack { response } end end end diff --git a/lib/scalingo/regional/environment.rb b/lib/scalingo/regional/environment.rb index 20ac83c..d9b0774 100644 --- a/lib/scalingo/regional/environment.rb +++ b/lib/scalingo/regional/environment.rb @@ -5,79 +5,67 @@ class Regional::Environment < API::Endpoint def for(app_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/variables", data, headers, &block ) - - unpack(:variables) { response } end def create(app_id, payload = {}, headers = nil, &block) data = {variable: payload} - response = connection.post( + connection.post( "apps/#{app_id}/variables", data, headers, &block ) - - unpack(:variable) { response } end def update(app_id, variable_id, value, headers = nil, &block) data = {variable: {value: value}} - response = connection.patch( + connection.patch( "apps/#{app_id}/variables/#{variable_id}", data, headers, &block ) - - unpack(:variable) { response } end def destroy(app_id, variable_id, headers = nil, &block) data = nil - response = connection.delete( + connection.delete( "apps/#{app_id}/variables/#{variable_id}", data, headers, &block ) - - unpack { response } end def bulk_update(app_id, variables, headers = nil, &block) data = {variables: variables} - response = connection.put( + connection.put( "apps/#{app_id}/variables", data, headers, &block ) - - unpack(:variables) { response } end def bulk_destroy(app_id, variable_ids, headers = nil, &block) data = {variable_ids: variable_ids} - response = connection.delete( + connection.delete( "apps/#{app_id}/variables", data, headers, &block ) - - unpack { response } end end end diff --git a/lib/scalingo/regional/events.rb b/lib/scalingo/regional/events.rb index d4d1684..582879c 100644 --- a/lib/scalingo/regional/events.rb +++ b/lib/scalingo/regional/events.rb @@ -3,53 +3,45 @@ class Regional::Events < API::Endpoint def all(payload = {}, headers = nil, &block) data = payload.compact - response = connection.get( + connection.get( "events", data, headers, &block ) - - unpack(:events) { response } end def for(app_id, payload = {}, headers = nil, &block) data = payload.compact - response = connection.get( + connection.get( "apps/#{app_id}/events", data, headers, &block ) - - unpack(:events) { response } end def types(headers = nil, &block) data = nil - response = connection(fallback_to_guest: true).get( + connection(fallback_to_guest: true).get( "event_types", data, headers, &block ) - - unpack(:event_types) { response } end def categories(headers = nil, &block) data = nil - response = connection(fallback_to_guest: true).get( + connection(fallback_to_guest: true).get( "event_categories", data, headers, &block ) - - unpack(:event_categories) { response } end end end diff --git a/lib/scalingo/regional/logs.rb b/lib/scalingo/regional/logs.rb index 9550a25..f86ffe1 100644 --- a/lib/scalingo/regional/logs.rb +++ b/lib/scalingo/regional/logs.rb @@ -3,27 +3,23 @@ class Regional::Logs < API::Endpoint def get(url, payload = {}, headers = nil, &block) data = payload.compact - response = connection(fallback_to_guest: true).get( + connection(fallback_to_guest: true).get( url, data, headers, &block ) - - unpack { response } end def archives(app_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/logs_archives", data, headers, &block ) - - unpack(:archives) { response } end ## Helper method to avoid having to manually chain two operations diff --git a/lib/scalingo/regional/metrics.rb b/lib/scalingo/regional/metrics.rb index e735530..3b2169a 100644 --- a/lib/scalingo/regional/metrics.rb +++ b/lib/scalingo/regional/metrics.rb @@ -16,27 +16,23 @@ def for(app_id, payload = {}, headers = nil, &block) url = "#{url}/#{payload[:container_index]}" if payload[:container_index] end - response = connection.get( + connection.get( url, data, headers, &block ) - - unpack { response } end def types(headers = nil, &block) data = nil - response = connection(fallback_to_guest: true).get( + connection(fallback_to_guest: true).get( "features/metrics", data, headers, &block ) - - unpack(:metrics) { response } end end end diff --git a/lib/scalingo/regional/notifiers.rb b/lib/scalingo/regional/notifiers.rb index 336097f..0dc8ffa 100644 --- a/lib/scalingo/regional/notifiers.rb +++ b/lib/scalingo/regional/notifiers.rb @@ -5,92 +5,78 @@ class Regional::Notifiers < API::Endpoint def for(app_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/notifiers", data, headers, &block ) - - unpack(:notifiers) { response } end def find(app_id, notifier_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/notifiers/#{notifier_id}", data, headers, &block ) - - unpack(:notifier) { response } end def create(app_id, payload = {}, headers = nil, &block) data = {notifier: payload} - response = connection.post( + connection.post( "apps/#{app_id}/notifiers", data, headers, &block ) - - unpack(:notifier) { response } end def update(app_id, notifier_id, payload = {}, headers = nil, &block) data = {notifier: payload} - response = connection.patch( + connection.patch( "apps/#{app_id}/notifiers/#{notifier_id}", data, headers, &block ) - - unpack(:notifier) { response } end def destroy(app_id, notifier_id, headers = nil, &block) data = nil - response = connection.delete( + connection.delete( "apps/#{app_id}/notifiers/#{notifier_id}", data, headers, &block ) - - unpack { response } end def test(app_id, notifier_id, headers = nil, &block) data = nil - response = connection.post( + connection.post( "apps/#{app_id}/notifiers/#{notifier_id}/test", data, headers, &block ) - - unpack { response } end def platforms(headers = nil, &block) data = nil - response = connection(fallback_to_guest: true).get( + connection(fallback_to_guest: true).get( "notification_platforms", data, headers, &block ) - - unpack(:notification_platforms) { response } end end end diff --git a/lib/scalingo/regional/operations.rb b/lib/scalingo/regional/operations.rb index 8c2310d..15ef6c1 100644 --- a/lib/scalingo/regional/operations.rb +++ b/lib/scalingo/regional/operations.rb @@ -13,14 +13,12 @@ def find(app_id, operation_id, headers = nil, &block) def get(url, headers = nil, &block) data = nil - response = connection.get( + connection.get( url, data, headers, &block ) - - unpack(:operation) { response } end end end diff --git a/lib/scalingo/regional/scm_repo_links.rb b/lib/scalingo/regional/scm_repo_links.rb index 9b904c6..deb9443 100644 --- a/lib/scalingo/regional/scm_repo_links.rb +++ b/lib/scalingo/regional/scm_repo_links.rb @@ -5,105 +5,89 @@ class Regional::ScmRepoLinks < API::Endpoint def show(app_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/scm_repo_link", data, headers, &block ) - - unpack(:scm_repo_link) { response } end def create(app_id, payload = {}, headers = nil, &block) data = {scm_repo_link: payload} - response = connection.post( + connection.post( "apps/#{app_id}/scm_repo_link", data, headers, &block ) - - unpack(:scm_repo_link) { response } end def update(app_id, payload = {}, headers = nil, &block) data = {scm_repo_link: payload} - response = connection.patch( + connection.patch( "apps/#{app_id}/scm_repo_link", data, headers, &block ) - - unpack(:scm_repo_link) { response } end def destroy(app_id, headers = nil, &block) data = nil - response = connection.delete( + connection.delete( "apps/#{app_id}/scm_repo_link", data, headers, &block ) - - unpack(:scm_repo_link) { response } end def deploy(app_id, branch, headers = nil, &block) data = {branch: branch} - response = connection.post( + connection.post( "apps/#{app_id}/scm_repo_link/manual_deploy", data, headers, &block ) - - unpack(:deployment) { response } end def review_app(review_app, pull_request_id, headers = nil, &block) data = {pull_request_id: pull_request_id} - response = connection.post( + connection.post( "apps/#{app_id}/scm_repo_link/manual_review_app", data, headers, &block ) - - unpack(:review_app) { response } end def branches(app_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/scm_repo_link/branches", data, headers, &block ) - - unpack(:branches) { response } end def pulls(app_id, headers = nil, &block) data = nil - response = connection.get( + connection.get( "apps/#{app_id}/scm_repo_link/pulls", data, headers, &block ) - - unpack(:pulls) { response } end end end diff --git a/lib/scalingo/regional_database/backups.rb b/lib/scalingo/regional_database/backups.rb index 0b835b0..4ccafc1 100644 --- a/lib/scalingo/regional_database/backups.rb +++ b/lib/scalingo/regional_database/backups.rb @@ -5,40 +5,34 @@ class RegionalDatabase::Backups < API::Endpoint def create(addon_id, headers = nil, &block) data = nil - response = database_connection(addon_id).post( + database_connection(addon_id).post( "databases/#{addon_id}/backups", data, headers, &block ) - - unpack(:database_backup) { response } end def for(addon_id, headers = nil, &block) data = nil - response = database_connection(addon_id).get( + database_connection(addon_id).get( "databases/#{addon_id}/backups", data, headers, &block ) - - unpack(:database_backups) { response } end def archive(addon_id, backup_id, headers = nil, &block) data = nil - response = database_connection(addon_id).get( + database_connection(addon_id).get( "databases/#{addon_id}/backups/#{backup_id}/archive", data, headers, &block ) - - unpack { response } end end end diff --git a/lib/scalingo/regional_database/databases.rb b/lib/scalingo/regional_database/databases.rb index fb56f87..f2d0ddb 100644 --- a/lib/scalingo/regional_database/databases.rb +++ b/lib/scalingo/regional_database/databases.rb @@ -5,27 +5,23 @@ class RegionalDatabase::Databases < API::Endpoint def find(id, headers = nil, &block) data = nil - response = database_connection(id).get( + database_connection(id).get( "databases/#{id}", data, headers, &block ) - - unpack(:database) { response } end def upgrade(id, headers = nil, &block) data = nil - response = database_connection(id).post( + database_connection(id).post( "databases/#{id}/upgrade", data, headers, &block ) - - unpack(:database) { response } end end end