red-api 0.2.1 → 0.2.2
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3137705ce3933690cf5048fc78576d68a7638499f8a9cdb18c59e83a7010fec
|
4
|
+
data.tar.gz: c01ba2e7a05de477e32e5441677b10f5f488fcd515d81897de746a358fe1fdd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48f9ed3cfc7b046bd5aab5b642322e42e86120905f474d76651aae224bad5fb1147024d445e23743de6bec8c66fee46b92bc29c33bbe700dfc20e070c7f2d87d
|
7
|
+
data.tar.gz: 74bb4846dab7e79cec7bc43da97f0d64bd4b0013fd18ff29ec328ac6adb657d25f01f1608867c61045694111e741e4b3ef13feaa93ef1e0b886adf318bf84e40
|
@@ -5,7 +5,7 @@ Description:
|
|
5
5
|
Will copy the --method-params given to your endpoint helper method to use in your endpoint URI path
|
6
6
|
|
7
7
|
Example:
|
8
|
-
rails generate endpoint ServiceName version EndpointName /endpoint/#{param1}/#{param2} --
|
8
|
+
rails generate endpoint ServiceName version EndpointName --endpoint /endpoint/#{param1}/#{param2} --endpoint-params param1 param2 --include-helper-params
|
9
9
|
|
10
10
|
Simple Form:
|
11
11
|
rails generate endpoint ServiceName V1 EndpointName /endpoint
|
@@ -3,8 +3,8 @@ class EndpointGenerator < Rails::Generators::NamedBase
|
|
3
3
|
|
4
4
|
argument :api_version, type: :string
|
5
5
|
argument :endpoint_name, type: :string
|
6
|
-
argument :endpoint, type: :string
|
7
6
|
|
7
|
+
class_option :endpoint, type: :string, default: '/'
|
8
8
|
class_option :method, type: :string, default: 'get'
|
9
9
|
class_option :endpoint_params, type: :array
|
10
10
|
class_option :include_helper_params
|
@@ -13,15 +13,17 @@ class EndpointGenerator < Rails::Generators::NamedBase
|
|
13
13
|
@api_service = file_name.underscore
|
14
14
|
@api_version = api_version
|
15
15
|
@endpoint_name = endpoint_name
|
16
|
-
@endpoint = endpoint
|
16
|
+
@endpoint = options[:endpoint]
|
17
17
|
|
18
|
-
raise ArgumentError 'Endpoint name required' unless @endpoint_name
|
19
|
-
raise ArgumentError '
|
18
|
+
raise ArgumentError, 'Endpoint name required' unless @endpoint_name
|
19
|
+
raise ArgumentError, 'Version is required, e.g. V1' unless @api_version
|
20
|
+
raise ArgumentError, 'Version should not be included in your endpoint, generator will build it for you' if @endpoint.downcase.include?(@api_version.downcase)
|
20
21
|
|
21
22
|
@endpoint_reference = @api_service.camelize + '::' + @api_version.camelize + '::ApiEndpoints'
|
22
23
|
@full_endpoint_reference = @endpoint_reference + '.' + @endpoint_name.underscore
|
23
24
|
|
24
|
-
@endpoint = @endpoint
|
25
|
+
@endpoint = '/' + @endpoint unless @endpoint.first == '/'
|
26
|
+
@endpoint = @api_version.downcase + @endpoint
|
25
27
|
@method = options[:method].to_sym
|
26
28
|
|
27
29
|
create_endpoint_params if options[:endpoint_params].present?
|
@@ -2,17 +2,16 @@ class ServiceGenerator < Rails::Generators::NamedBase
|
|
2
2
|
source_root File.expand_path('templates', __dir__)
|
3
3
|
|
4
4
|
argument :version, type: :string
|
5
|
-
|
5
|
+
class_option :api_endpoint, type: :string, default: 'https://'
|
6
6
|
class_option :key, type: :array
|
7
7
|
|
8
8
|
def create_api_service
|
9
9
|
@api_name = file_name
|
10
10
|
@api_version = version
|
11
|
-
@api_endpoint = api_endpoint
|
11
|
+
@api_endpoint = options[:api_endpoint]
|
12
12
|
@env_var_opts = options[:key]
|
13
13
|
|
14
14
|
raise ArgumentError, 'Need to give the API version' unless @api_version.present?
|
15
|
-
raise ArgumentError, 'Need to give the API endpoint URI e.g. https://api/' unless @api_endpoint.present?
|
16
15
|
|
17
16
|
@full_api_reference = @api_name.camelize + '::' + @api_version.upcase
|
18
17
|
@api_endpoint = @api_endpoint + '/' unless @api_endpoint.last == '/'
|