Skip to content

Commit

Permalink
Add Zaikio::Hub::AccessToken (#154)
Browse files Browse the repository at this point in the history
* Add Zaikio::Hub::AccessToken

* Reorganize hub classes and introduce breaking change for VendorApp

* Disable uri

---------

Co-authored-by: Jalyna <js@zaikio.com>
  • Loading branch information
PolinaStamenova and jalyna authored Sep 28, 2023
1 parent b1c1f9d commit 538adbe
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- **BREAKING** Rename `Zaikio::Hub::App` to `Zaikio::Hub::VendorApp`
- Add `Zaikio::Hub::App` for apps meta data arriving from the new access token endpoint
- Add `Zaikio::Hub::Vendor`
- Add `Zaikio::Hub::AccessToken`

## [0.18.0]

- Add `reference` attribute to `Availability`
Expand Down
5 changes: 4 additions & 1 deletion lib/zaikio/hub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# Models
require "zaikio/hub/client"
require "zaikio/hub/base"
require "zaikio/hub/app"
require "zaikio/hub/vendor"
require "zaikio/hub/asset"
require "zaikio/hub/organization_membership"
require "zaikio/hub/business_relationship"
Expand All @@ -24,11 +26,12 @@
require "zaikio/hub/role"
require "zaikio/hub/revoked_access_token"
require "zaikio/hub/connection"
require "zaikio/hub/app"
require "zaikio/hub/subscription"
require "zaikio/hub/subscription_invitation"
require "zaikio/hub/test_account"
require "zaikio/hub/token_data"
require "zaikio/hub/access_token"
require "zaikio/hub/vendor_app"

module Zaikio
module Hub
Expand Down
12 changes: 12 additions & 0 deletions lib/zaikio/hub/access_token.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Zaikio
module Hub
class AccessToken < Base
uri "access_token"

include_root_in_json :access_token

# Associations
has_one :app, class_name: "Zaikio::Hub::App", uri: nil
end
end
end
9 changes: 5 additions & 4 deletions lib/zaikio/hub/app.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module Zaikio
module Hub
class App < Base
uri "apps(/:id)"

include_root_in_json :app
uri nil

# Attributes
attributes :name, :category, :kind, :state, :configuration
attributes :name, :slug, :title, :logo_url

# Associations
has_one :vendor, class_name: "Zaikio::Hub::Vendor", uri: nil
end
end
end
2 changes: 1 addition & 1 deletion lib/zaikio/hub/current_organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def self.find_with_fallback(fallback)
# For vendors
has_many :connections, class_name: "Zaikio::Hub::Connection",
uri: "connections(/:id)"
has_many :apps, class_name: "Zaikio::Hub::App",
has_many :apps, class_name: "Zaikio::Hub::VendorApp",
uri: "apps(/:id)"

def fetch
Expand Down
10 changes: 10 additions & 0 deletions lib/zaikio/hub/vendor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Zaikio
module Hub
class Vendor < Base
uri nil

# Attributes
attributes :name, :slug, :logo_url
end
end
end
12 changes: 12 additions & 0 deletions lib/zaikio/hub/vendor_app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Zaikio
module Hub
class VendorApp < Base
uri "apps(/:id)"

include_root_in_json :app

# Attributes
attributes :name, :category, :kind, :state, :configuration
end
end
end

0 comments on commit 538adbe

Please sign in to comment.