zaikio-directory 0.0.11 → 0.1.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 +5 -1
- data/lib/zaikio/directory.rb +4 -2
- data/lib/zaikio/directory/configuration.rb +5 -5
- data/lib/zaikio/directory/connection.rb +11 -1
- data/lib/zaikio/directory/subscription.rb +27 -0
- data/lib/zaikio/directory/version.rb +1 -1
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a72248c2cce21c6086f28c1973032fb48be5a3090887209dd0eff98441506fe1
|
4
|
+
data.tar.gz: 6e7bd4cee9fe02cc0faae2f2acfd67eae92346951e9500df050865402996f001
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73add47c0e748bf676d5dc0d1db7da71ae5e5393d191b68eb14025f936dee92cff0e9933db56201d33a03e4b51cd992a14c3ecb7aaf1ce531a6599c490ad34f6
|
7
|
+
data.tar.gz: c8e8b679d75533d493090edc93fce47db3ab884833499fd1a40cd238df650583db86c3cb5d3197e3b792cb04b210dfb42db52496bc357b430c114dd7f47d28c6
|
data/README.md
CHANGED
@@ -35,7 +35,7 @@ end
|
|
35
35
|
|
36
36
|
The Directory Client has an ORM like design. However, we distinguish between the contexts of the organization and the person.
|
37
37
|
|
38
|
-
For the requests to work, a valid JSON Web token with the correct OAuth Scopes must always be provided. Please refer to [zakio-oauth_client](
|
38
|
+
For the requests to work, a valid JSON Web token with the correct OAuth Scopes must always be provided. Please refer to [zakio-oauth_client](https://github.com/crispymtn/zaikio-oauth_client).
|
39
39
|
|
40
40
|
If you want to know which actions are available and which scopes are required, please refer to the [Directory API Reference](https://docs.zaikio.com/api/directory/directory.html).
|
41
41
|
|
@@ -97,6 +97,10 @@ end
|
|
97
97
|
```rb
|
98
98
|
Zaikio::Directory.with_basic_auth(client_id, client_secret) do
|
99
99
|
connections = Zaikio::Directory::Connection.all
|
100
|
+
subscription = Zaikio::Directory::Subscription.find("Organization-b1475f65-236c-58b8-96e1-e1778b43beb7")
|
101
|
+
subscription.plan # => "advanced"
|
102
|
+
subscription.activate!
|
103
|
+
subscription.increment_usage_by!(:orders_created, 12)
|
100
104
|
end
|
101
105
|
|
102
106
|
roles = Zaikio::Directory::Role.all
|
data/lib/zaikio/directory.rb
CHANGED
@@ -23,6 +23,7 @@ require "zaikio/directory/current_organization"
|
|
23
23
|
require "zaikio/directory/role"
|
24
24
|
require "zaikio/directory/revoked_access_token"
|
25
25
|
require "zaikio/directory/connection"
|
26
|
+
require "zaikio/directory/subscription"
|
26
27
|
|
27
28
|
module Zaikio
|
28
29
|
module Directory
|
@@ -61,7 +62,8 @@ module Zaikio
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def create_connection
|
64
|
-
self.connection = Faraday.new(url: "#{configuration.host}/api/v1"
|
65
|
+
self.connection = Faraday.new(url: "#{configuration.host}/api/v1",
|
66
|
+
ssl: { verify: configuration.environment != :test }) do |c|
|
65
67
|
c.request :json
|
66
68
|
c.response :logger, configuration&.logger
|
67
69
|
c.use JSONParser
|
@@ -73,7 +75,7 @@ module Zaikio
|
|
73
75
|
|
74
76
|
private
|
75
77
|
|
76
|
-
def create_token_data(payload)
|
78
|
+
def create_token_data(payload)
|
77
79
|
subjects = payload["sub"].split(">")
|
78
80
|
|
79
81
|
OpenStruct.new(
|
@@ -4,11 +4,11 @@ module Zaikio
|
|
4
4
|
module Directory
|
5
5
|
class Configuration
|
6
6
|
HOSTS = {
|
7
|
-
development: "
|
8
|
-
test: "
|
9
|
-
staging: "https://
|
10
|
-
sandbox: "https://
|
11
|
-
production: "https://
|
7
|
+
development: "https://hub.zaikio.test",
|
8
|
+
test: "https://hub.zaikio.test",
|
9
|
+
staging: "https://hub.staging.zaikio.com",
|
10
|
+
sandbox: "https://hub.sandbox.zaikio.com",
|
11
|
+
production: "https://hub.zaikio.com"
|
12
12
|
}.freeze
|
13
13
|
|
14
14
|
attr_accessor :host
|
@@ -1,9 +1,19 @@
|
|
1
1
|
module Zaikio
|
2
2
|
module Directory
|
3
3
|
class Connection < Base
|
4
|
-
uri "connections"
|
4
|
+
uri "connections(/:id)"
|
5
5
|
|
6
6
|
include_root_in_json :connection
|
7
|
+
|
8
|
+
def initialize(attributes = {})
|
9
|
+
if attributes["connectable_id"]
|
10
|
+
super(attributes.merge(
|
11
|
+
"id" => "#{attributes['connectable_type']}-#{attributes['connectable_id']}"
|
12
|
+
))
|
13
|
+
else
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
7
17
|
end
|
8
18
|
end
|
9
19
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Zaikio
|
2
|
+
module Directory
|
3
|
+
class Subscription < Base
|
4
|
+
uri "subscriptions(/:id)"
|
5
|
+
|
6
|
+
include_root_in_json :subscription
|
7
|
+
|
8
|
+
def initialize(attributes = {})
|
9
|
+
if attributes["subscriber_id"]
|
10
|
+
super(attributes.merge(
|
11
|
+
"id" => "#{attributes['subscriber_type']}-#{attributes['subscriber_id']}"
|
12
|
+
))
|
13
|
+
else
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def activate!
|
19
|
+
update(status: "active")
|
20
|
+
end
|
21
|
+
|
22
|
+
def increment_usage_by!(usage, by = 1)
|
23
|
+
update(increment_usages_in_current_billing_period: { usage => by })
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zaikio-directory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- crispymtn
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-08-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: jwt
|
@@ -30,16 +30,22 @@ dependencies:
|
|
30
30
|
name: multi_json
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - "
|
33
|
+
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: 1.14.1
|
36
|
+
- - "<"
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 1.16.0
|
36
39
|
type: :runtime
|
37
40
|
prerelease: false
|
38
41
|
version_requirements: !ruby/object:Gem::Requirement
|
39
42
|
requirements:
|
40
|
-
- - "
|
43
|
+
- - ">="
|
41
44
|
- !ruby/object:Gem::Version
|
42
45
|
version: 1.14.1
|
46
|
+
- - "<"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.16.0
|
43
49
|
- !ruby/object:Gem::Dependency
|
44
50
|
name: oj
|
45
51
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,6 +107,7 @@ files:
|
|
101
107
|
- lib/zaikio/directory/site.rb
|
102
108
|
- lib/zaikio/directory/software.rb
|
103
109
|
- lib/zaikio/directory/specialist.rb
|
110
|
+
- lib/zaikio/directory/subscription.rb
|
104
111
|
- lib/zaikio/directory/version.rb
|
105
112
|
- lib/zaikio/error.rb
|
106
113
|
homepage: https://www.zaikio.com/
|