gocardless-pro 0.1.1 → 0.2.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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -4
  3. data/lib/gocardless-pro.rb +1 -169
  4. data/lib/gocardless-pro/api_service.rb +2 -2
  5. data/lib/gocardless-pro/client.rb +135 -0
  6. data/lib/gocardless-pro/version.rb +1 -1
  7. data/spec/api_service_spec.rb +3 -2
  8. data/spec/client_spec.rb +4 -14
  9. data/spec/services/creditor_bank_account_service_spec.rb +1 -2
  10. data/spec/services/creditor_service_spec.rb +1 -2
  11. data/spec/services/customer_bank_account_service_spec.rb +1 -2
  12. data/spec/services/customer_service_spec.rb +1 -2
  13. data/spec/services/event_service_spec.rb +1 -2
  14. data/spec/services/helper_service_spec.rb +1 -2
  15. data/spec/services/mandate_service_spec.rb +1 -2
  16. data/spec/services/payment_service_spec.rb +1 -2
  17. data/spec/services/payout_service_spec.rb +1 -2
  18. data/spec/services/redirect_flow_service_spec.rb +1 -2
  19. data/spec/services/refund_service_spec.rb +1 -2
  20. data/spec/services/subscription_service_spec.rb +1 -2
  21. metadata +2 -25
  22. data/lib/gocardless-pro/resources/api_key.rb +0 -62
  23. data/lib/gocardless-pro/resources/publishable_api_key.rb +0 -51
  24. data/lib/gocardless-pro/resources/role.rb +0 -101
  25. data/lib/gocardless-pro/resources/user.rb +0 -60
  26. data/lib/gocardless-pro/services/api_key_service.rb +0 -130
  27. data/lib/gocardless-pro/services/publishable_api_key_service.rb +0 -130
  28. data/lib/gocardless-pro/services/role_service.rb +0 -127
  29. data/lib/gocardless-pro/services/user_service.rb +0 -148
  30. data/spec/resources/api_key_spec.rb +0 -85
  31. data/spec/resources/publishable_api_key_spec.rb +0 -63
  32. data/spec/resources/role_spec.rb +0 -63
  33. data/spec/resources/user_spec.rb +0 -85
  34. data/spec/services/api_key_service_spec.rb +0 -362
  35. data/spec/services/publishable_api_key_service_spec.rb +0 -336
  36. data/spec/services/role_service_spec.rb +0 -336
  37. data/spec/services/user_service_spec.rb +0 -433
@@ -1,130 +0,0 @@
1
- require_relative './base_service'
2
-
3
- # encoding: utf-8
4
- #
5
- # WARNING: Do not edit by hand, this file was generated by Crank:
6
- #
7
- # https://github.com/gocardless/crank
8
-
9
- module GoCardless
10
- module Services
11
- # Service for making requests to the ApiKey endpoints
12
- class ApiKeyService < BaseService
13
- # Creates a new API key.
14
- # Example URL: /api_keys
15
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
16
- # Else, they will be the body of the request.
17
- def create(options = {}, custom_headers = {})
18
- path = '/api_keys'
19
- new_options = {}
20
- new_options[envelope_key] = options
21
- options = new_options
22
- response = make_request(:post, path, options, custom_headers)
23
-
24
- Resources::ApiKey.new(unenvelope_body(response.body))
25
- end
26
-
27
- # Returns a
28
- # [cursor-paginated](https://developer.gocardless.com/pro/#overview-cursor-pagination)
29
- # list of your API keys.
30
- # Example URL: /api_keys
31
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
32
- # Else, they will be the body of the request.
33
- def list(options = {}, custom_headers = {})
34
- path = '/api_keys'
35
-
36
- response = make_request(:get, path, options, custom_headers)
37
- ListResponse.new(
38
- raw_response: response,
39
- unenveloped_body: unenvelope_body(response.body),
40
- resource_class: Resources::ApiKey
41
- )
42
- end
43
-
44
- # Get a lazily enumerated list of all the items returned. This is simmilar to the `list` method but will paginate for you automatically.
45
- #
46
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
47
- # Otherwise they will be the body of the request.
48
- def all(options = {})
49
- Paginator.new(
50
- service: self,
51
- path: '/api_keys',
52
- options: options
53
- ).enumerator
54
- end
55
-
56
- # Retrieves the details of an existing API key.
57
- # Example URL: /api_keys/:identity
58
- #
59
- # @param identity # Unique identifier, beginning with "AK"
60
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
61
- # Else, they will be the body of the request.
62
- def get(identity, options = {}, custom_headers = {})
63
- path = sub_url('/api_keys/:identity', 'identity' => identity)
64
-
65
- response = make_request(:get, path, options, custom_headers)
66
-
67
- Resources::ApiKey.new(unenvelope_body(response.body))
68
- end
69
-
70
- # Updates an API key. Only the `name` and `webhook_url` fields are supported.
71
- # Example URL: /api_keys/:identity
72
- #
73
- # @param identity # Unique identifier, beginning with "AK"
74
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
75
- # Else, they will be the body of the request.
76
- def update(identity, options = {}, custom_headers = {})
77
- path = sub_url('/api_keys/:identity', 'identity' => identity)
78
-
79
- new_options = {}
80
- new_options[envelope_key] = options
81
- options = new_options
82
- response = make_request(:put, path, options, custom_headers)
83
-
84
- Resources::ApiKey.new(unenvelope_body(response.body))
85
- end
86
-
87
- # Disables an API key. Once disabled, the API key will not be usable to
88
- # authenticate any requests, and its `webhook_url` will not receive any more
89
- # events.
90
- # Example URL: /api_keys/:identity/actions/disable
91
- #
92
- # @param identity # Unique identifier, beginning with "AK"
93
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
94
- # Else, they will be the body of the request.
95
- def disable(identity, options = {}, custom_headers = {})
96
- path = sub_url('/api_keys/:identity/actions/disable', 'identity' => identity)
97
-
98
- new_options = {}
99
- new_options['data'] = options
100
- options = new_options
101
- response = make_request(:post, path, options, custom_headers)
102
-
103
- Resources::ApiKey.new(unenvelope_body(response.body))
104
- end
105
-
106
- # Unenvelope the response of the body using the service's `envelope_key`
107
- #
108
- # @param body [Hash]
109
- def unenvelope_body(body)
110
- body[envelope_key] || body['data']
111
- end
112
-
113
- private
114
-
115
- # return the key which API responses will envelope data under
116
- def envelope_key
117
- 'api_keys'
118
- end
119
-
120
- # take a URL with placeholder params and substitute them out for the acutal value
121
- # @param url [String] the URL with placeholders in
122
- # @param param_map [Hash] a hash of placeholders and their actual values
123
- def sub_url(url, param_map)
124
- param_map.reduce(url) do |new_url, (param, value)|
125
- new_url.gsub(":#{param}", value)
126
- end
127
- end
128
- end
129
- end
130
- end
@@ -1,130 +0,0 @@
1
- require_relative './base_service'
2
-
3
- # encoding: utf-8
4
- #
5
- # WARNING: Do not edit by hand, this file was generated by Crank:
6
- #
7
- # https://github.com/gocardless/crank
8
-
9
- module GoCardless
10
- module Services
11
- # Service for making requests to the PublishableApiKey endpoints
12
- class PublishableApiKeyService < BaseService
13
- # Creates a publishable API key object.
14
- # Example URL: /publishable_api_keys
15
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
16
- # Else, they will be the body of the request.
17
- def create(options = {}, custom_headers = {})
18
- path = '/publishable_api_keys'
19
- new_options = {}
20
- new_options[envelope_key] = options
21
- options = new_options
22
- response = make_request(:post, path, options, custom_headers)
23
-
24
- Resources::PublishableApiKey.new(unenvelope_body(response.body))
25
- end
26
-
27
- # Returns a
28
- # [cursor-paginated](https://developer.gocardless.com/pro/#overview-cursor-pagination)
29
- # list of your publishable API keys
30
- # Example URL: /publishable_api_keys
31
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
32
- # Else, they will be the body of the request.
33
- def list(options = {}, custom_headers = {})
34
- path = '/publishable_api_keys'
35
-
36
- response = make_request(:get, path, options, custom_headers)
37
- ListResponse.new(
38
- raw_response: response,
39
- unenveloped_body: unenvelope_body(response.body),
40
- resource_class: Resources::PublishableApiKey
41
- )
42
- end
43
-
44
- # Get a lazily enumerated list of all the items returned. This is simmilar to the `list` method but will paginate for you automatically.
45
- #
46
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
47
- # Otherwise they will be the body of the request.
48
- def all(options = {})
49
- Paginator.new(
50
- service: self,
51
- path: '/publishable_api_keys',
52
- options: options
53
- ).enumerator
54
- end
55
-
56
- # Returns all details about a single publishable API key
57
- # Example URL: /publishable_api_keys/:identity
58
- #
59
- # @param identity # Unique identifier, beginning with "PK"
60
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
61
- # Else, they will be the body of the request.
62
- def get(identity, options = {}, custom_headers = {})
63
- path = sub_url('/publishable_api_keys/:identity', 'identity' => identity)
64
-
65
- response = make_request(:get, path, options, custom_headers)
66
-
67
- Resources::PublishableApiKey.new(unenvelope_body(response.body))
68
- end
69
-
70
- # Updates a publishable API key. Only the `name` fields are supported. Any other
71
- # fields passed will be ignored.
72
- # Example URL: /publishable_api_keys/:identity
73
- #
74
- # @param identity # Unique identifier, beginning with "PK"
75
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
76
- # Else, they will be the body of the request.
77
- def update(identity, options = {}, custom_headers = {})
78
- path = sub_url('/publishable_api_keys/:identity', 'identity' => identity)
79
-
80
- new_options = {}
81
- new_options[envelope_key] = options
82
- options = new_options
83
- response = make_request(:put, path, options, custom_headers)
84
-
85
- Resources::PublishableApiKey.new(unenvelope_body(response.body))
86
- end
87
-
88
- # Disables a publishable API key. Once disabled, the publishable API key will
89
- # not be usable to authenticate any requests.
90
- # Example URL: /publishable_api_keys/:identity/actions/disable
91
- #
92
- # @param identity # Unique identifier, beginning with "PK"
93
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
94
- # Else, they will be the body of the request.
95
- def disable(identity, options = {}, custom_headers = {})
96
- path = sub_url('/publishable_api_keys/:identity/actions/disable', 'identity' => identity)
97
-
98
- new_options = {}
99
- new_options['data'] = options
100
- options = new_options
101
- response = make_request(:post, path, options, custom_headers)
102
-
103
- Resources::PublishableApiKey.new(unenvelope_body(response.body))
104
- end
105
-
106
- # Unenvelope the response of the body using the service's `envelope_key`
107
- #
108
- # @param body [Hash]
109
- def unenvelope_body(body)
110
- body[envelope_key] || body['data']
111
- end
112
-
113
- private
114
-
115
- # return the key which API responses will envelope data under
116
- def envelope_key
117
- 'publishable_api_keys'
118
- end
119
-
120
- # take a URL with placeholder params and substitute them out for the acutal value
121
- # @param url [String] the URL with placeholders in
122
- # @param param_map [Hash] a hash of placeholders and their actual values
123
- def sub_url(url, param_map)
124
- param_map.reduce(url) do |new_url, (param, value)|
125
- new_url.gsub(":#{param}", value)
126
- end
127
- end
128
- end
129
- end
130
- end
@@ -1,127 +0,0 @@
1
- require_relative './base_service'
2
-
3
- # encoding: utf-8
4
- #
5
- # WARNING: Do not edit by hand, this file was generated by Crank:
6
- #
7
- # https://github.com/gocardless/crank
8
-
9
- module GoCardless
10
- module Services
11
- # Service for making requests to the Role endpoints
12
- class RoleService < BaseService
13
- # Create a role with set access permissions
14
- # Example URL: /roles
15
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
16
- # Else, they will be the body of the request.
17
- def create(options = {}, custom_headers = {})
18
- path = '/roles'
19
- new_options = {}
20
- new_options[envelope_key] = options
21
- options = new_options
22
- response = make_request(:post, path, options, custom_headers)
23
-
24
- Resources::Role.new(unenvelope_body(response.body))
25
- end
26
-
27
- # List all existing roles
28
- # Example URL: /roles
29
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
30
- # Else, they will be the body of the request.
31
- def list(options = {}, custom_headers = {})
32
- path = '/roles'
33
-
34
- response = make_request(:get, path, options, custom_headers)
35
- ListResponse.new(
36
- raw_response: response,
37
- unenveloped_body: unenvelope_body(response.body),
38
- resource_class: Resources::Role
39
- )
40
- end
41
-
42
- # Get a lazily enumerated list of all the items returned. This is simmilar to the `list` method but will paginate for you automatically.
43
- #
44
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
45
- # Otherwise they will be the body of the request.
46
- def all(options = {})
47
- Paginator.new(
48
- service: self,
49
- path: '/roles',
50
- options: options
51
- ).enumerator
52
- end
53
-
54
- # Retrieve all details for a single role
55
- # Example URL: /roles/:identity
56
- #
57
- # @param identity # Unique identifier, beginning with "RO"
58
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
59
- # Else, they will be the body of the request.
60
- def get(identity, options = {}, custom_headers = {})
61
- path = sub_url('/roles/:identity', 'identity' => identity)
62
-
63
- response = make_request(:get, path, options, custom_headers)
64
-
65
- Resources::Role.new(unenvelope_body(response.body))
66
- end
67
-
68
- # Updates a role object. Supports all of the fields supported when creating a
69
- # role.
70
- # Example URL: /roles/:identity
71
- #
72
- # @param identity # Unique identifier, beginning with "RO"
73
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
74
- # Else, they will be the body of the request.
75
- def update(identity, options = {}, custom_headers = {})
76
- path = sub_url('/roles/:identity', 'identity' => identity)
77
-
78
- new_options = {}
79
- new_options[envelope_key] = options
80
- options = new_options
81
- response = make_request(:put, path, options, custom_headers)
82
-
83
- Resources::Role.new(unenvelope_body(response.body))
84
- end
85
-
86
- # Disables a role
87
- # Example URL: /roles/:identity/actions/disable
88
- #
89
- # @param identity # Unique identifier, beginning with "RO"
90
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
91
- # Else, they will be the body of the request.
92
- def disable(identity, options = {}, custom_headers = {})
93
- path = sub_url('/roles/:identity/actions/disable', 'identity' => identity)
94
-
95
- new_options = {}
96
- new_options['data'] = options
97
- options = new_options
98
- response = make_request(:post, path, options, custom_headers)
99
-
100
- Resources::Role.new(unenvelope_body(response.body))
101
- end
102
-
103
- # Unenvelope the response of the body using the service's `envelope_key`
104
- #
105
- # @param body [Hash]
106
- def unenvelope_body(body)
107
- body[envelope_key] || body['data']
108
- end
109
-
110
- private
111
-
112
- # return the key which API responses will envelope data under
113
- def envelope_key
114
- 'roles'
115
- end
116
-
117
- # take a URL with placeholder params and substitute them out for the acutal value
118
- # @param url [String] the URL with placeholders in
119
- # @param param_map [Hash] a hash of placeholders and their actual values
120
- def sub_url(url, param_map)
121
- param_map.reduce(url) do |new_url, (param, value)|
122
- new_url.gsub(":#{param}", value)
123
- end
124
- end
125
- end
126
- end
127
- end
@@ -1,148 +0,0 @@
1
- require_relative './base_service'
2
-
3
- # encoding: utf-8
4
- #
5
- # WARNING: Do not edit by hand, this file was generated by Crank:
6
- #
7
- # https://github.com/gocardless/crank
8
-
9
- module GoCardless
10
- module Services
11
- # Service for making requests to the User endpoints
12
- class UserService < BaseService
13
- # <a name="user_exists"></a>Creates a new user object. Email addresses must be
14
- # unique.
15
- # Example URL: /users
16
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
17
- # Else, they will be the body of the request.
18
- def create(options = {}, custom_headers = {})
19
- path = '/users'
20
- new_options = {}
21
- new_options[envelope_key] = options
22
- options = new_options
23
- response = make_request(:post, path, options, custom_headers)
24
-
25
- Resources::User.new(unenvelope_body(response.body))
26
- end
27
-
28
- # Returns a
29
- # [cursor-paginated](https://developer.gocardless.com/pro/#overview-cursor-pagination)
30
- # list of your users.
31
- # Example URL: /users
32
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
33
- # Else, they will be the body of the request.
34
- def list(options = {}, custom_headers = {})
35
- path = '/users'
36
-
37
- response = make_request(:get, path, options, custom_headers)
38
- ListResponse.new(
39
- raw_response: response,
40
- unenveloped_body: unenvelope_body(response.body),
41
- resource_class: Resources::User
42
- )
43
- end
44
-
45
- # Get a lazily enumerated list of all the items returned. This is simmilar to the `list` method but will paginate for you automatically.
46
- #
47
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
48
- # Otherwise they will be the body of the request.
49
- def all(options = {})
50
- Paginator.new(
51
- service: self,
52
- path: '/users',
53
- options: options
54
- ).enumerator
55
- end
56
-
57
- # Retrieves the details of an existing user. In addition to the usual
58
- # permissions based access rules, any user can access their own record.
59
- # Example URL: /users/:identity
60
- #
61
- # @param identity # Unique identifier, beginning with "US"
62
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
63
- # Else, they will be the body of the request.
64
- def get(identity, options = {}, custom_headers = {})
65
- path = sub_url('/users/:identity', 'identity' => identity)
66
-
67
- response = make_request(:get, path, options, custom_headers)
68
-
69
- Resources::User.new(unenvelope_body(response.body))
70
- end
71
-
72
- # Updates a user object. Supports all of the fields supported when creating a
73
- # user.
74
- # Example URL: /users/:identity
75
- #
76
- # @param identity # Unique identifier, beginning with "US"
77
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
78
- # Else, they will be the body of the request.
79
- def update(identity, options = {}, custom_headers = {})
80
- path = sub_url('/users/:identity', 'identity' => identity)
81
-
82
- new_options = {}
83
- new_options[envelope_key] = options
84
- options = new_options
85
- response = make_request(:put, path, options, custom_headers)
86
-
87
- Resources::User.new(unenvelope_body(response.body))
88
- end
89
-
90
- # Enables a user
91
- # Example URL: /users/:identity/actions/enable
92
- #
93
- # @param identity # Unique identifier, beginning with "US"
94
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
95
- # Else, they will be the body of the request.
96
- def enable(identity, options = {}, custom_headers = {})
97
- path = sub_url('/users/:identity/actions/enable', 'identity' => identity)
98
-
99
- new_options = {}
100
- new_options['data'] = options
101
- options = new_options
102
- response = make_request(:post, path, options, custom_headers)
103
-
104
- Resources::User.new(unenvelope_body(response.body))
105
- end
106
-
107
- # Disables a user
108
- # Example URL: /users/:identity/actions/disable
109
- #
110
- # @param identity # Unique identifier, beginning with "US"
111
- # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
112
- # Else, they will be the body of the request.
113
- def disable(identity, options = {}, custom_headers = {})
114
- path = sub_url('/users/:identity/actions/disable', 'identity' => identity)
115
-
116
- new_options = {}
117
- new_options['data'] = options
118
- options = new_options
119
- response = make_request(:post, path, options, custom_headers)
120
-
121
- Resources::User.new(unenvelope_body(response.body))
122
- end
123
-
124
- # Unenvelope the response of the body using the service's `envelope_key`
125
- #
126
- # @param body [Hash]
127
- def unenvelope_body(body)
128
- body[envelope_key] || body['data']
129
- end
130
-
131
- private
132
-
133
- # return the key which API responses will envelope data under
134
- def envelope_key
135
- 'users'
136
- end
137
-
138
- # take a URL with placeholder params and substitute them out for the acutal value
139
- # @param url [String] the URL with placeholders in
140
- # @param param_map [Hash] a hash of placeholders and their actual values
141
- def sub_url(url, param_map)
142
- param_map.reduce(url) do |new_url, (param, value)|
143
- new_url.gsub(":#{param}", value)
144
- end
145
- end
146
- end
147
- end
148
- end