scalingo 3.0.0.beta.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/publish.yml +28 -0
  3. data/.github/workflows/ruby.yml +45 -0
  4. data/.rubocop.yml +16 -0
  5. data/CHANGELOG.md +24 -0
  6. data/README.md +25 -20
  7. data/lib/scalingo/api/client.rb +38 -10
  8. data/lib/scalingo/api/endpoint.rb +12 -2
  9. data/lib/scalingo/api/response.rb +11 -2
  10. data/lib/scalingo/auth/keys.rb +4 -4
  11. data/lib/scalingo/auth/scm_integrations.rb +4 -4
  12. data/lib/scalingo/auth/tokens.rb +6 -6
  13. data/lib/scalingo/auth/two_factor_auth.rb +4 -4
  14. data/lib/scalingo/auth/user.rb +15 -2
  15. data/lib/scalingo/bearer_token.rb +15 -0
  16. data/lib/scalingo/billing/profile.rb +3 -3
  17. data/lib/scalingo/client.rb +26 -113
  18. data/lib/scalingo/configuration.rb +8 -36
  19. data/lib/scalingo/core_client.rb +106 -0
  20. data/lib/scalingo/regional/addons.rb +21 -8
  21. data/lib/scalingo/regional/apps.rb +8 -8
  22. data/lib/scalingo/regional/autoscalers.rb +70 -0
  23. data/lib/scalingo/regional/collaborators.rb +4 -4
  24. data/lib/scalingo/regional/containers.rb +4 -4
  25. data/lib/scalingo/regional/deployments.rb +3 -3
  26. data/lib/scalingo/regional/domains.rb +5 -5
  27. data/lib/scalingo/regional/environment.rb +6 -6
  28. data/lib/scalingo/regional/events.rb +4 -4
  29. data/lib/scalingo/regional/logs.rb +2 -2
  30. data/lib/scalingo/regional/metrics.rb +3 -2
  31. data/lib/scalingo/regional/notifiers.rb +7 -7
  32. data/lib/scalingo/regional/operations.rb +1 -1
  33. data/lib/scalingo/regional/scm_repo_links.rb +8 -8
  34. data/lib/scalingo/regional.rb +2 -0
  35. data/lib/scalingo/token_holder.rb +31 -0
  36. data/lib/scalingo/version.rb +1 -1
  37. data/samples/auth/user/stop-free-trial.json +24 -0
  38. data/samples/regional/addons/token-200.json +49 -0
  39. data/samples/regional/addons/token-404.json +24 -0
  40. data/samples/regional/autoscalers/_meta.json +27 -0
  41. data/samples/regional/autoscalers/create-201.json +49 -0
  42. data/samples/regional/autoscalers/create-500.json +32 -0
  43. data/samples/regional/autoscalers/destroy-204.json +20 -0
  44. data/samples/regional/autoscalers/destroy-404.json +25 -0
  45. data/samples/regional/autoscalers/find-200.json +39 -0
  46. data/samples/regional/autoscalers/find-404.json +25 -0
  47. data/samples/regional/autoscalers/for-200.json +41 -0
  48. data/samples/regional/autoscalers/update-200.json +45 -0
  49. data/samples/regional/autoscalers/update-404.json +31 -0
  50. data/samples/regional/autoscalers/update-500.json +30 -0
  51. data/scalingo.gemspec +8 -8
  52. data/spec/scalingo/api/client_spec.rb +60 -13
  53. data/spec/scalingo/api/endpoint_spec.rb +18 -3
  54. data/spec/scalingo/api/response_spec.rb +32 -16
  55. data/spec/scalingo/auth/user_spec.rb +6 -0
  56. data/spec/scalingo/auth_spec.rb +1 -1
  57. data/spec/scalingo/billing_spec.rb +11 -0
  58. data/spec/scalingo/client_spec.rb +2 -2
  59. data/spec/scalingo/configuration_spec.rb +32 -30
  60. data/spec/scalingo/regional/addons_spec.rb +16 -0
  61. data/spec/scalingo/regional/autoscalers_spec.rb +84 -0
  62. data/spec/scalingo/regional_spec.rb +3 -3
  63. metadata +69 -47
  64. data/.travis.yml +0 -24
@@ -1,131 +1,44 @@
1
- require "forwardable"
2
- require "faraday"
3
- require "faraday_middleware"
4
- require "scalingo/bearer_token"
5
- require "scalingo/errors"
1
+ require "scalingo/core_client"
6
2
  require "scalingo/auth"
7
3
  require "scalingo/billing"
8
4
  require "scalingo/regional"
9
5
 
10
6
  module Scalingo
11
- class Client
12
- extend Forwardable
13
-
14
- attr_reader :config
15
-
16
- def initialize(attributes = {})
17
- @config = Configuration.new(attributes, Scalingo.config)
18
-
19
- define_regions!
20
- end
21
-
22
- ## Authentication helpers / Token management
23
- attr_reader :token
24
-
25
- def token=(input)
26
- @token = input.is_a?(BearerToken) ? input : BearerToken.new(input.to_s, raise_on_expired: config.raise_on_expired_token)
27
- end
28
-
29
- def authenticated?
30
- token.present? && !token.expired?
31
- end
32
-
33
- def authenticate_with(access_token: nil, bearer_token: nil, expires_at: nil)
34
- if !access_token && !bearer_token
35
- raise ArgumentError, "You must supply one of `access_token` or `bearer_token`"
36
- end
37
-
38
- if access_token && bearer_token
39
- raise ArgumentError, "You cannot supply both `access_token` and `bearer_token`"
40
- end
41
-
42
- if expires_at && !bearer_token
43
- raise ArgumentError, "`expires_at` can only be used with `bearer_token`. `access_token` have a 1 hour expiration."
44
- end
45
-
46
- if access_token
47
- expiration = Time.now + config.exchanged_token_validity
48
- response = auth.tokens.exchange(access_token)
49
-
50
- if response.successful?
51
- self.token = BearerToken.new(
52
- response.data[:token],
53
- expires_at: expiration,
54
- raise_on_expired: config.raise_on_expired_token,
55
- )
56
- end
57
-
58
- return response.successful?
59
- end
60
-
61
- if bearer_token
62
- self.token = if expires_at
63
- token = bearer_token.is_a?(BearerToken) ? bearer_token.value : bearer_token.to_s
64
-
65
- BearerToken.new(
66
- token,
67
- expires_at: expires_at,
68
- raise_on_expired: config.raise_on_expired_token,
69
- )
70
- else
71
- bearer_token
72
- end
73
-
74
- true
75
- end
76
- end
77
-
7
+ class Client < CoreClient
78
8
  ## API clients
79
9
  def auth
80
- @auth ||= Auth.new(self, config.auth)
10
+ @auth ||= Auth.new(
11
+ "https://auth.scalingo.com/v1",
12
+ scalingo: self,
13
+ )
81
14
  end
82
15
 
83
16
  def billing
84
- @billing ||= Billing.new(self, config.billing)
17
+ @billing ||= Billing.new(
18
+ "https://cashmachine.scalingo.com",
19
+ scalingo: self,
20
+ )
85
21
  end
86
22
 
87
- def region(name = nil)
88
- public_send(name || config.default_region)
23
+ def agora_fr1
24
+ @agora_fr1 ||= Regional.new(
25
+ "https://api.agora-fr1.scalingo.com/v1",
26
+ scalingo: self,
27
+ )
89
28
  end
90
29
 
91
- ## Delegations
92
- def_delegator :auth, :keys
93
- def_delegator :auth, :scm_integrations
94
- def_delegator :auth, :tokens
95
- def_delegator :auth, :two_factor_auth
96
- def_delegator :auth, :tfa
97
- def_delegator :auth, :user
98
-
99
- def_delegator :region, :addons
100
- def_delegator :region, :apps
101
- def_delegator :region, :collaborators
102
- def_delegator :region, :containers
103
- def_delegator :region, :deployments
104
- def_delegator :region, :domains
105
- def_delegator :region, :environment
106
- def_delegator :region, :events
107
- def_delegator :region, :logs
108
- def_delegator :region, :metrics
109
- def_delegator :region, :notifiers
110
- def_delegator :region, :operations
111
- def_delegator :region, :scm_repo_links
112
-
113
- private
114
-
115
- def define_regions!
116
- config.regions.each_pair do |region, _|
117
- define_singleton_method(region) do
118
- region_client = instance_variable_get :"@#{region}"
119
-
120
- unless region_client
121
- region_client = Regional.new(self, config.regions.public_send(region))
122
-
123
- instance_variable_set :"@#{region}", region_client
124
- end
30
+ def osc_fr1
31
+ @osc_fr1 ||= Regional.new(
32
+ "https://api.osc-fr1.scalingo.com/v1",
33
+ scalingo: self,
34
+ )
35
+ end
125
36
 
126
- region_client
127
- end
128
- end
37
+ def osc_secnum_fr1
38
+ @osc_secnum_fr1 ||= Regional.new(
39
+ "https://api.osc-secnum-fr1.scalingo.com/v1",
40
+ scalingo: self,
41
+ )
129
42
  end
130
43
  end
131
44
  end
@@ -1,3 +1,4 @@
1
+ require "active_support"
1
2
  require "active_support/core_ext/numeric/time"
2
3
  require "scalingo/version"
3
4
  require "ostruct"
@@ -6,20 +7,17 @@ module Scalingo
6
7
  class Configuration
7
8
  ATTRIBUTES = [
8
9
  # URL to the authentication API
9
- :auth,
10
+ # :auth,
10
11
 
11
12
  # URL to the billing API
12
- :billing,
13
+ # :billing,
13
14
 
14
15
  # List of regions under the form {"region_id": root_url}
15
- :regions,
16
+ # :regions,
16
17
 
17
18
  # Default region. Must match a key in `regions`
18
19
  :default_region,
19
20
 
20
- # Wether to use https or http
21
- :https,
22
-
23
21
  # Configure the User Agent header
24
22
  :user_agent,
25
23
 
@@ -36,20 +34,16 @@ module Scalingo
36
34
 
37
35
  # These headers will be added to every request. Individual methods may override them.
38
36
  # This should be a hash or a callable object that returns a hash.
39
- :additional_headers
37
+ :additional_headers,
38
+
39
+ # Specify an adapter for faraday. Leave nil for the default one (Net::HTTP)
40
+ :faraday_adapter,
40
41
  ]
41
42
 
42
43
  ATTRIBUTES.each { |attr| attr_accessor(attr) }
43
44
 
44
45
  def self.default
45
46
  new(
46
- auth: "https://auth.scalingo.com/v1",
47
- billing: "https://cashmachine.scalingo.com",
48
- regions: {
49
- agora_fr1: "https://api.agora-fr1.scalingo.com/v1",
50
- osc_fr1: "https://api.osc-fr1.scalingo.com/v1",
51
- osc_secnum_fr1: "https://api.osc-secnum-fr1.scalingo.com/v1"
52
- },
53
47
  default_region: :osc_fr1,
54
48
  user_agent: "Scalingo Ruby Client v#{Scalingo::VERSION}",
55
49
  exchanged_token_validity: 1.hour,
@@ -64,28 +58,6 @@ module Scalingo
64
58
  public_send("#{name}=", attributes.fetch(name, parent&.public_send(name)))
65
59
  end
66
60
  end
67
-
68
- def regions=(input)
69
- if input.is_a?(OpenStruct)
70
- @regions = input
71
- return
72
- end
73
-
74
- if input.is_a?(Hash)
75
- @regions = OpenStruct.new(input)
76
- return
77
- end
78
-
79
- raise ArgumentError, "wrong type for argument"
80
- end
81
-
82
- def default_region=(input)
83
- input = input.to_sym
84
-
85
- raise ArgumentError, "No regions named `#{input}`" unless regions.respond_to?(input)
86
-
87
- @default_region = input
88
- end
89
61
  end
90
62
 
91
63
  def self.config
@@ -0,0 +1,106 @@
1
+ require "forwardable"
2
+ require "faraday"
3
+ require "faraday_middleware"
4
+ require "scalingo/token_holder"
5
+ require "scalingo/errors"
6
+
7
+ module Scalingo
8
+ class CoreClient
9
+ extend Forwardable
10
+ include TokenHolder
11
+
12
+ attr_reader :config
13
+
14
+ def initialize(attributes = {})
15
+ @config = Configuration.new(attributes, Scalingo.config)
16
+ end
17
+
18
+ def inspect
19
+ str = %(<#{self.class}:0x#{object_id.to_s(16)} version:"#{Scalingo::VERSION}" authenticated:)
20
+
21
+ str << if token.present?
22
+ (token.expired? ? "expired" : "true")
23
+ else
24
+ "false"
25
+ end
26
+
27
+ str << ">"
28
+ str
29
+ end
30
+
31
+ ## Sub-clients accessors
32
+ def auth
33
+ raise NotImplementedError
34
+ end
35
+
36
+ def billing
37
+ raise NotImplementedError
38
+ end
39
+
40
+ def region(name = nil)
41
+ public_send(name || config.default_region)
42
+ end
43
+
44
+ ## Authentication helpers / Token management
45
+ def authenticate_with(access_token: nil, bearer_token: nil, expires_at: nil)
46
+ if !access_token && !bearer_token
47
+ raise ArgumentError, "You must supply one of `access_token` or `bearer_token`"
48
+ end
49
+
50
+ if access_token && bearer_token
51
+ raise ArgumentError, "You cannot supply both `access_token` and `bearer_token`"
52
+ end
53
+
54
+ if expires_at && !bearer_token
55
+ raise ArgumentError, "`expires_at` can only be used with `bearer_token`. `access_token` have a 1 hour expiration."
56
+ end
57
+
58
+ if access_token
59
+ expiration = Time.now + config.exchanged_token_validity
60
+ response = auth.tokens.exchange(access_token)
61
+
62
+ if response.successful?
63
+ self.token = BearerToken.new(
64
+ response.data[:token],
65
+ expires_at: expiration,
66
+ raise_on_expired: config.raise_on_expired_token,
67
+ )
68
+ end
69
+
70
+ return response.successful?
71
+ end
72
+
73
+ if bearer_token
74
+ authenticate_with_bearer_token(
75
+ bearer_token,
76
+ expires_at: expires_at,
77
+ raise_on_expired_token: config.raise_on_expired_token,
78
+ )
79
+
80
+ true
81
+ end
82
+ end
83
+
84
+ ## Delegations
85
+ def_delegator :auth, :keys
86
+ def_delegator :auth, :scm_integrations
87
+ def_delegator :auth, :tokens
88
+ def_delegator :auth, :two_factor_auth
89
+ def_delegator :auth, :tfa
90
+ def_delegator :auth, :user
91
+
92
+ def_delegator :region, :addons
93
+ def_delegator :region, :apps
94
+ def_delegator :region, :collaborators
95
+ def_delegator :region, :containers
96
+ def_delegator :region, :deployments
97
+ def_delegator :region, :domains
98
+ def_delegator :region, :environment
99
+ def_delegator :region, :events
100
+ def_delegator :region, :logs
101
+ def_delegator :region, :metrics
102
+ def_delegator :region, :notifiers
103
+ def_delegator :region, :operations
104
+ def_delegator :region, :scm_repo_links
105
+ end
106
+ end
@@ -12,7 +12,7 @@ module Scalingo
12
12
  &block
13
13
  )
14
14
 
15
- unpack(response, key: :addons)
15
+ unpack(:addons) { response }
16
16
  end
17
17
 
18
18
  def find(app_id, addon_id, headers = nil, &block)
@@ -25,7 +25,7 @@ module Scalingo
25
25
  &block
26
26
  )
27
27
 
28
- unpack(response, key: :addon)
28
+ unpack(:addon) { response }
29
29
  end
30
30
 
31
31
  def provision(app_id, payload = {}, headers = nil, &block)
@@ -38,7 +38,7 @@ module Scalingo
38
38
  &block
39
39
  )
40
40
 
41
- unpack(response, key: :addon)
41
+ unpack(:addon) { response }
42
42
  end
43
43
 
44
44
  def update(app_id, addon_id, payload = {}, headers = nil, &block)
@@ -51,7 +51,7 @@ module Scalingo
51
51
  &block
52
52
  )
53
53
 
54
- unpack(response, key: :addon)
54
+ unpack(:addon) { response }
55
55
  end
56
56
 
57
57
  def destroy(app_id, addon_id, headers = nil, &block)
@@ -64,7 +64,7 @@ module Scalingo
64
64
  &block
65
65
  )
66
66
 
67
- unpack(response)
67
+ unpack { response }
68
68
  end
69
69
 
70
70
  def sso(app_id, addon_id, headers = nil, &block)
@@ -77,7 +77,20 @@ module Scalingo
77
77
  &block
78
78
  )
79
79
 
80
- unpack(response, key: :addon)
80
+ unpack(:addon) { response }
81
+ end
82
+
83
+ def token(app_id, addon_id, headers = nil, &block)
84
+ data = nil
85
+
86
+ response = connection.post(
87
+ "apps/#{app_id}/addons/#{addon_id}/token",
88
+ data,
89
+ headers,
90
+ &block
91
+ )
92
+
93
+ unpack(:addon) { response }
81
94
  end
82
95
 
83
96
  def categories(headers = nil, &block)
@@ -90,7 +103,7 @@ module Scalingo
90
103
  &block
91
104
  )
92
105
 
93
- unpack(response, key: :addon_categories)
106
+ unpack(:addon_categories) { response }
94
107
  end
95
108
 
96
109
  def providers(headers = nil, &block)
@@ -103,7 +116,7 @@ module Scalingo
103
116
  &block
104
117
  )
105
118
 
106
- unpack(response, key: :addon_providers)
119
+ unpack(:addon_providers) { response }
107
120
  end
108
121
  end
109
122
  end
@@ -12,7 +12,7 @@ module Scalingo
12
12
  &block
13
13
  )
14
14
 
15
- unpack(response, key: :apps)
15
+ unpack(:apps) { response }
16
16
  end
17
17
 
18
18
  def find(id, headers = nil, &block)
@@ -25,7 +25,7 @@ module Scalingo
25
25
  &block
26
26
  )
27
27
 
28
- unpack(response, key: :app)
28
+ unpack(:app) { response }
29
29
  end
30
30
 
31
31
  def create(payload = {}, headers = nil, &block)
@@ -44,7 +44,7 @@ module Scalingo
44
44
  &block
45
45
  )
46
46
 
47
- unpack(response, key: :app)
47
+ unpack(:app) { response }
48
48
  end
49
49
 
50
50
  def update(id, payload = {}, headers = nil, &block)
@@ -57,7 +57,7 @@ module Scalingo
57
57
  &block
58
58
  )
59
59
 
60
- unpack(response, key: :app)
60
+ unpack(:app) { response }
61
61
  end
62
62
 
63
63
  def logs_url(id, headers = nil, &block)
@@ -70,7 +70,7 @@ module Scalingo
70
70
  &block
71
71
  )
72
72
 
73
- unpack(response, key: :logs_url)
73
+ unpack(:logs_url) { response }
74
74
  end
75
75
 
76
76
  def destroy(id, payload = {}, headers = nil, &block)
@@ -81,7 +81,7 @@ module Scalingo
81
81
  &block
82
82
  )
83
83
 
84
- unpack(response)
84
+ unpack { response }
85
85
  end
86
86
 
87
87
  def rename(id, payload = {}, headers = nil, &block)
@@ -92,7 +92,7 @@ module Scalingo
92
92
  &block
93
93
  )
94
94
 
95
- unpack(response, key: :app)
95
+ unpack(:app) { response }
96
96
  end
97
97
 
98
98
  def transfer(id, payload = {}, headers = nil, &block)
@@ -103,7 +103,7 @@ module Scalingo
103
103
  &block
104
104
  )
105
105
 
106
- unpack(response, key: :app)
106
+ unpack(:app) { response }
107
107
  end
108
108
  end
109
109
  end
@@ -0,0 +1,70 @@
1
+ require "scalingo/api/endpoint"
2
+
3
+ module Scalingo
4
+ class Regional::Autoscalers < API::Endpoint
5
+ def for(app_id, headers = nil, &block)
6
+ data = nil
7
+
8
+ response = connection.get(
9
+ "apps/#{app_id}/autoscalers",
10
+ data,
11
+ headers,
12
+ &block
13
+ )
14
+
15
+ unpack(:autoscalers) { response }
16
+ end
17
+
18
+ def find(app_id, autoscaler_id, headers = nil, &block)
19
+ data = nil
20
+
21
+ response = connection.get(
22
+ "apps/#{app_id}/autoscalers/#{autoscaler_id}",
23
+ data,
24
+ headers,
25
+ &block
26
+ )
27
+
28
+ unpack(:autoscaler) { response }
29
+ end
30
+
31
+ def create(app_id, payload = {}, headers = nil, &block)
32
+ data = {autoscaler: payload}
33
+
34
+ response = connection.post(
35
+ "apps/#{app_id}/autoscalers",
36
+ data,
37
+ headers,
38
+ &block
39
+ )
40
+
41
+ unpack(:autoscaler) { response }
42
+ end
43
+
44
+ def update(app_id, autoscaler_id, payload = {}, headers = nil, &block)
45
+ data = {autoscaler: payload}
46
+
47
+ response = connection.patch(
48
+ "apps/#{app_id}/autoscalers/#{autoscaler_id}",
49
+ data,
50
+ headers,
51
+ &block
52
+ )
53
+
54
+ unpack(:autoscaler) { response }
55
+ end
56
+
57
+ def destroy(app_id, autoscaler_id, headers = nil, &block)
58
+ data = nil
59
+
60
+ response = connection.delete(
61
+ "apps/#{app_id}/autoscalers/#{autoscaler_id}",
62
+ data,
63
+ headers,
64
+ &block
65
+ )
66
+
67
+ unpack { response }
68
+ end
69
+ end
70
+ end
@@ -12,7 +12,7 @@ module Scalingo
12
12
  &block
13
13
  )
14
14
 
15
- unpack(response, key: :collaborators)
15
+ unpack(:collaborators) { response }
16
16
  end
17
17
 
18
18
  def destroy(app_id, collaborator_id, headers = nil, &block)
@@ -25,7 +25,7 @@ module Scalingo
25
25
  &block
26
26
  )
27
27
 
28
- unpack(response)
28
+ unpack { response }
29
29
  end
30
30
 
31
31
  def invite(app_id, payload = {}, headers = nil, &block)
@@ -38,7 +38,7 @@ module Scalingo
38
38
  &block
39
39
  )
40
40
 
41
- unpack(response, key: :collaborator)
41
+ unpack(:collaborator) { response }
42
42
  end
43
43
 
44
44
  def accept(token, headers = nil, &block)
@@ -51,7 +51,7 @@ module Scalingo
51
51
  &block
52
52
  )
53
53
 
54
- unpack(response)
54
+ unpack { response }
55
55
  end
56
56
  end
57
57
  end
@@ -12,7 +12,7 @@ module Scalingo
12
12
  &block
13
13
  )
14
14
 
15
- unpack(response, key: :containers)
15
+ unpack(:containers) { response }
16
16
  end
17
17
 
18
18
  def scale(app_id, formation, headers = nil, &block)
@@ -25,7 +25,7 @@ module Scalingo
25
25
  &block
26
26
  )
27
27
 
28
- unpack(response, key: :containers)
28
+ unpack(:containers) { response }
29
29
  end
30
30
 
31
31
  def restart(app_id, scope = [], headers = nil, &block)
@@ -38,7 +38,7 @@ module Scalingo
38
38
  &block
39
39
  )
40
40
 
41
- unpack(response)
41
+ unpack { response }
42
42
  end
43
43
 
44
44
  def sizes(headers = nil, &block)
@@ -51,7 +51,7 @@ module Scalingo
51
51
  &block
52
52
  )
53
53
 
54
- unpack(response, key: :container_sizes)
54
+ unpack(:container_sizes) { response }
55
55
  end
56
56
  end
57
57
  end
@@ -12,7 +12,7 @@ module Scalingo
12
12
  &block
13
13
  )
14
14
 
15
- unpack(response, key: :deployments)
15
+ unpack(:deployments) { response }
16
16
  end
17
17
 
18
18
  def find(app_id, deployment_id, headers = nil, &block)
@@ -25,7 +25,7 @@ module Scalingo
25
25
  &block
26
26
  )
27
27
 
28
- unpack(response, key: :deployment)
28
+ unpack(:deployment) { response }
29
29
  end
30
30
 
31
31
  def logs(app_id, deployment_id, headers = nil, &block)
@@ -38,7 +38,7 @@ module Scalingo
38
38
  &block
39
39
  )
40
40
 
41
- unpack(response, key: :deployment)
41
+ unpack(:deployment) { response }
42
42
  end
43
43
  end
44
44
  end
@@ -12,7 +12,7 @@ module Scalingo
12
12
  &block
13
13
  )
14
14
 
15
- unpack(response, key: :domains)
15
+ unpack(:domains) { response }
16
16
  end
17
17
 
18
18
  def find(app_id, domain_id, headers = nil, &block)
@@ -25,7 +25,7 @@ module Scalingo
25
25
  &block
26
26
  )
27
27
 
28
- unpack(response, key: :domain)
28
+ unpack(:domain) { response }
29
29
  end
30
30
 
31
31
  def create(app_id, payload = {}, headers = nil, &block)
@@ -38,7 +38,7 @@ module Scalingo
38
38
  &block
39
39
  )
40
40
 
41
- unpack(response, key: :domain)
41
+ unpack(:domain) { response }
42
42
  end
43
43
 
44
44
  def update(app_id, domain_id, payload = {}, headers = nil, &block)
@@ -51,7 +51,7 @@ module Scalingo
51
51
  &block
52
52
  )
53
53
 
54
- unpack(response, key: :domain)
54
+ unpack(:domain) { response }
55
55
  end
56
56
 
57
57
  def destroy(app_id, domain_id, headers = nil, &block)
@@ -64,7 +64,7 @@ module Scalingo
64
64
  &block
65
65
  )
66
66
 
67
- unpack(response)
67
+ unpack { response }
68
68
  end
69
69
  end
70
70
  end