blazer_json_api 0.1.2 → 0.1.3

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: 59f80fa45e2a211955055a9833d63c75115e7a7b7ddc80dff0953551cb98994c
4
- data.tar.gz: 004add471a763d719345a3c2de853d0ccbdadd432ffaddcaed8d63c51de7a08a
3
+ metadata.gz: dd329ef99930168a04d81e45b6c66b8dba865f624ae90c115d54822ba8638db8
4
+ data.tar.gz: 0e16b3de5dc5f23ed9ea4b266a20d0341dccebb7a2c5cfe7f059f3058ede8926
5
5
  SHA512:
6
- metadata.gz: c3936cafc9e5edebc527d3dff0618e42f8544e816c6cc6b8dce611169a7cec1a77eb5984582d4a701164dc0562013f003ccbc74ae12904e0f0d53a1cfae85b04
7
- data.tar.gz: 9673d8c148f944fbb24fa3914b655961153eaf95a0a2fc91ce30de532fd465f089fc0b2ace2690cbf2b49c70e4d8a88cbd61f865927c50a7d0084e7cff015268
6
+ metadata.gz: d6d2f729fca9746581cc5184f02ad64fe96e028930fb3e7f4f9c49dc74870865c27c1d18f8f5d8be745404d2e227b917bb46abf6d1311537449bbb3fda9cd63e
7
+ data.tar.gz: 14b0d4e8138fcdd12c9710f1db35570eb026c8c0bd2a722c666f0183b04673183439679efea599614079f716ecd1f4bd1e4c6e10c0458550a92c567cf390a0b5
data/README.md CHANGED
@@ -98,16 +98,20 @@ e.g. `/blazer-api/queries/1-all-users?username=blazer_john`
98
98
 
99
99
  It would result in the following response.
100
100
 
101
- ```json
102
- {
103
- "id":2,
104
- "username":"blazer_john",
105
- "first_name":"John",
106
- "last_name":"Doyle",
107
- "email":"john.doyle@gmail.com",
108
- "country":"USA"
109
- }
101
+ #### Using a variable/url parameter conditionally (e.g. optional filter)
102
+
103
+ It's possible to make a filter optional directly in SQL as follows
104
+
105
+ ```sql
106
+ SELECT id, username, first_name, last_name, email, country
107
+ FROM users
108
+ WHERE {username} IS NULL OR username={username}
110
109
  ```
110
+
111
+ In this scenario, the url parameter/filter for `username` is optional.
112
+
113
+ If provided it will apply the filter, if not provided, it will return an unfiltered response.
114
+
111
115
  #### Controlling response structure
112
116
  Standard queries return flat JSON responses that correspond to the results table from executing the SQL.
113
117
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module BlazerJsonApi
3
+ module BlazerJsonAPI
4
4
  class ApplicationController < ActionController::Base
5
5
 
6
6
  if BlazerJsonAPI.credentials_provided?
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module BlazerJsonApi
4
- class QueriesController < ApplicationController
3
+ module BlazerJsonAPI
4
+ class QueriesController < BlazerJsonAPI::ApplicationController
5
5
  before_action :set_query
6
6
 
7
7
  def show
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module BlazerJsonApi
3
+ module BlazerJsonAPI
4
4
  module ApplicationHelper
5
5
  end
6
6
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module BlazerJsonApi
3
+ module BlazerJsonAPI
4
4
  class ApplicationJob < ActiveJob::Base
5
5
  end
6
6
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module BlazerJsonApi
3
+ module BlazerJsonAPI
4
4
  class ApplicationMailer < ActionMailer::Base
5
5
  default from: 'from@example.com'
6
6
  layout 'mailer'
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module BlazerJsonApi
3
+ module BlazerJsonAPI
4
4
  class ApplicationRecord < ActiveRecord::Base
5
5
  self.abstract_class = true
6
6
  end
@@ -14,8 +14,6 @@ module BlazerJsonAPI
14
14
  end
15
15
 
16
16
  def call
17
- return unless bind_variables.all? { |v| params[v] }
18
-
19
17
  bind_variables.each do |variable|
20
18
  value = params[variable].presence
21
19
  if value
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BlazerJsonAPI
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blazer_json_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Farrell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-05 00:00:00.000000000 Z
11
+ date: 2021-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties