stellar_federation-rails 0.1.0 → 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.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/app/controllers/stellar_federation/api/v1/queries_controller.rb +12 -19
- data/app/models/stellar_federation/query.rb +8 -0
- data/app/services/stellar_federation/queries/check_parameters.rb +7 -2
- data/app/services/stellar_federation/queries/parse_address_name.rb +19 -0
- data/app/services/stellar_federation/queries/process_query.rb +2 -0
- data/app/services/stellar_federation/queries/trigger_on_query_callback_class.rb +2 -2
- data/lib/stellar_federation/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2a5dd9c599f9a33cd232b074bebb2c94f7cb429d824cc0a7b559e4a11736bd6
|
4
|
+
data.tar.gz: 4011c7b3bd8dc0d51ed2f1ba0d36c3721109f18e2e05ae48a6901e5a56d4e850
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e5192333665c01abf43ec5e33de7363df91ea03552ef3df2f4d41737e1a14507ec8f837e6f92eafbff59a34bb9800cedac7669174b4aa3e978fd2027730c980
|
7
|
+
data.tar.gz: c68aa010040e7bcb817242af6f541d168cf0b44c745f8933ded7513cd73ec86292b9b37676d51ea2a3811cc8cd8c3572194158814e18596ea29298dd3e9a875d
|
data/README.md
CHANGED
@@ -47,8 +47,10 @@ StellarFederation.configure do |c|
|
|
47
47
|
end
|
48
48
|
```
|
49
49
|
|
50
|
-
`c.on_query` - is a class the you define: The `on_query` class should also return a `StellarFederation::QueryResponse`. If it doesn't, the Rails engine will throw an exception. The `on_query` class will be called with `.call`,
|
50
|
+
`c.on_query` - is a class the you define: The `on_query` class should also return a `StellarFederation::QueryResponse`. If it doesn't, the Rails engine will throw an exception. The `on_query` class will be called with `.call`, that accepts a `StellarFederation::Query` object
|
51
51
|
- `address_name` - ex: `tunder_adebayo*your_org.com`
|
52
|
+
- `address_id` - ex: `tunder_adebayo`
|
53
|
+
- `address_domain` - ex: `your_org.com`
|
52
54
|
|
53
55
|
Add to your routes:
|
54
56
|
|
@@ -3,30 +3,23 @@ module StellarFederation
|
|
3
3
|
module V1
|
4
4
|
class QueriesController < ApplicationController
|
5
5
|
def index
|
6
|
-
|
6
|
+
result = Queries::ProcessQuery.(query_params: query_params)
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
.
|
8
|
+
respond_to do |format|
|
9
|
+
format.json do
|
10
|
+
if result.success?
|
11
|
+
@query_response = result.query_response
|
11
12
|
|
12
|
-
respond_to do |format|
|
13
|
-
format.json do
|
14
13
|
render json: @query_response.to_json, status: :ok
|
14
|
+
else
|
15
|
+
json_status = {
|
16
|
+
status: "Unprocessable Entity",
|
17
|
+
message: result.message,
|
18
|
+
}
|
19
|
+
|
20
|
+
render json: json_status, status: :unprocessable_entity
|
15
21
|
end
|
16
22
|
end
|
17
|
-
else
|
18
|
-
respond_to do |format|
|
19
|
-
format.json do
|
20
|
-
render(
|
21
|
-
json: {
|
22
|
-
status: "Unprocessable Entity",
|
23
|
-
message: "Invalid Parameters",
|
24
|
-
},
|
25
|
-
status: :unprocessable_entity,
|
26
|
-
)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
23
|
end
|
31
24
|
|
32
25
|
end
|
@@ -1,8 +1,13 @@
|
|
1
1
|
module StellarFederation
|
2
2
|
module Queries
|
3
3
|
class CheckParameters
|
4
|
-
|
5
|
-
|
4
|
+
extend LightService::Action
|
5
|
+
expects :query_params
|
6
|
+
|
7
|
+
executed do |c|
|
8
|
+
unless c.query_params[:q].present? && check_type(c.query_params[:type])
|
9
|
+
c.fail! "Invalid Parameters"
|
10
|
+
end
|
6
11
|
end
|
7
12
|
|
8
13
|
private
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module StellarFederation
|
2
|
+
module Queries
|
3
|
+
class ParseAddressName
|
4
|
+
extend LightService::Action
|
5
|
+
expects :query_params
|
6
|
+
promises :query
|
7
|
+
|
8
|
+
executed do |c|
|
9
|
+
address_name = c.query_params[:address_name]
|
10
|
+
split_address_name = address_name.split("*")
|
11
|
+
c.query = Query.new(
|
12
|
+
address_id: split_address_name[0],
|
13
|
+
address_domain: split_address_name[1],
|
14
|
+
address_name: address_name,
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -2,12 +2,12 @@ module StellarFederation
|
|
2
2
|
module Queries
|
3
3
|
class TriggerOnQueryCallbackClass
|
4
4
|
extend LightService::Action
|
5
|
-
expects :
|
5
|
+
expects :query
|
6
6
|
promises :query_response
|
7
7
|
|
8
8
|
executed do |c|
|
9
9
|
begin
|
10
|
-
c.query_response = callback_class.(c.
|
10
|
+
c.query_response = callback_class.(c.query)
|
11
11
|
|
12
12
|
if !c.query_response.is_a? StellarFederation::QueryResponse
|
13
13
|
raise_return_error
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stellar_federation-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ace Subido
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -114,8 +114,10 @@ files:
|
|
114
114
|
- app/mailers/stellar_federation/application_mailer.rb
|
115
115
|
- app/models/stellar_federation/application_record.rb
|
116
116
|
- app/models/stellar_federation/base_model.rb
|
117
|
+
- app/models/stellar_federation/query.rb
|
117
118
|
- app/models/stellar_federation/query_response.rb
|
118
119
|
- app/services/stellar_federation/queries/check_parameters.rb
|
120
|
+
- app/services/stellar_federation/queries/parse_address_name.rb
|
119
121
|
- app/services/stellar_federation/queries/prepare_on_query_parameters.rb
|
120
122
|
- app/services/stellar_federation/queries/process_query.rb
|
121
123
|
- app/services/stellar_federation/queries/trigger_on_query_callback_class.rb
|