This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class App < ApplicationRecord | |
| validates :name, uniqueness: true | |
| validates :token, uniqueness: true | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rails.application.routes.draw do | |
| # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | |
| root 'application#index', format: 'json' | |
| namespace :v1 do | |
| resource :apps | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class V1::AppsController < ApplicationController | |
| before_action :set_app, only: [:show, :update, :destroy] | |
| # GET /v1/apps | |
| def index | |
| @apps = App.all | |
| render json: @apps | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| http | role | route | |
|---|---|---|---|
| GET | Get an app | /v1/apps/{int:id} | |
| GET | Get all apps | /v1/apps/ | |
| POST | Create an app | /v1/apps/ | |
| PATCH | Update an app | /v1/apps/{int:id} | |
| DELETE | Delete an app | /v1/apps/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ApplicationController < ActionController::API | |
| def index | |
| render json: { status: 200, message: 'Hello World'} | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rails.application.routes.draw do | |
| # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | |
| root 'application#index', format: 'json' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rails.application.routes.draw do | |
| # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CreateApps < ActiveRecord::Migration[5.2] | |
| def change | |
| create_table :apps do |t| | |
| # Name of our app, used for visual readability. | |
| t.string :name, unique: true | |
| # Internal identifier of our app, for communication from the open api endpoint | |
| t.string :token, unique: true | |
| # Switch to determine if this app is currently accepting data. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ApiHelper | |
| include Rack::Test::Methods | |
| def app | |
| Rails.application | |
| end | |
| end | |
| RSpec.configure do |config| | |
| config.include ApiHelper, api: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select order_Id from [order] o where( | |
| o.order_id in ( | |
| select osh.order_id | |
| from order_status_history osh | |
| join order_status os on os.status_id = osh.status_id | |
| inner join ( | |
| select order_id, MAX(effective_date) as updated | |
| from order_status_history | |
| group by order_id) as status on osh.order_id = status.order_id and osh.effective_date = status.updated |