eventline 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 +7 -0
- data/lib/eventline/account.rb +95 -0
- data/lib/eventline/client.rb +165 -0
- data/lib/eventline/context.rb +106 -0
- data/lib/eventline/event.rb +117 -0
- data/lib/eventline/organization.rb +57 -0
- data/lib/eventline/version.rb +17 -0
- data/lib/eventline.rb +12 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 56cd182c51702104d9373178ba4ccf90b980d347a599c25ba7355558aa971f7a
|
4
|
+
data.tar.gz: 99b125a4950034ee3e9c0e7a154c142a35d2ea90e984b0800ca859c31363624e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '0778b80c81259626f335a5cbcf021960a55e37d118d6fa34fcfc70741bae4ab3172df81226d2dc31bbc6ab31f985defa9cb2546d98806c0609d7be42ad342b05'
|
7
|
+
data.tar.gz: 3f31538d02f8779c2436a23bbacf0e5f5252d7a9a483c0e0046fae6e6ab2fd152db51512774897524f27a0939fe0093ade72c3620d0c4c459b46e8ba97e14855
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# Copyright (c) 2021-2022 Exograd SAS.
|
2
|
+
#
|
3
|
+
# Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
# purpose with or without fee is hereby granted, provided that the above
|
5
|
+
# copyright notice and this permission notice appear in all copies.
|
6
|
+
#
|
7
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
|
15
|
+
require("eventline/client")
|
16
|
+
|
17
|
+
module Eventline
|
18
|
+
class Account
|
19
|
+
attr_accessor(:id, :org_id, :creation_time, :disabled, :email_address, :name, :role,
|
20
|
+
:last_login_time, :last_project_id, :settings)
|
21
|
+
|
22
|
+
# Fetch a list of accounts.
|
23
|
+
#
|
24
|
+
# @param [Eventline::Client] client
|
25
|
+
# @param [Hash] data
|
26
|
+
#
|
27
|
+
# @raise [Eventline::Client::RequestError]
|
28
|
+
#
|
29
|
+
# @return Eventline::Client::ListResponse
|
30
|
+
def self.list(client, data = nil)
|
31
|
+
request = Net::HTTP::Get.new("/v0/accounts")
|
32
|
+
response = client.call(request)
|
33
|
+
|
34
|
+
elements = response.fetch("elements", []).map do |element|
|
35
|
+
account = new
|
36
|
+
account.from_h(element)
|
37
|
+
account
|
38
|
+
end
|
39
|
+
|
40
|
+
Client::ListResponse.new(elements, response["next"], response["previous"])
|
41
|
+
end
|
42
|
+
|
43
|
+
# Fetch an account by identifier.
|
44
|
+
#
|
45
|
+
# @param [Eventline::Client] client
|
46
|
+
# @param [String] id
|
47
|
+
#
|
48
|
+
# @raise [Eventline::Client::RequestError]
|
49
|
+
#
|
50
|
+
# @return Eventline::Account
|
51
|
+
def self.retrieve(client, id)
|
52
|
+
request = Net::HTTP::Get.new(File.join("/v0/accounts/id", id))
|
53
|
+
response = client.call(request)
|
54
|
+
account = new
|
55
|
+
account.from_h(response)
|
56
|
+
account
|
57
|
+
end
|
58
|
+
|
59
|
+
# Fetch the current account.
|
60
|
+
#
|
61
|
+
# @param [Eventline::Client] client
|
62
|
+
#
|
63
|
+
# @raise [Eventline::Client::RequestError]
|
64
|
+
#
|
65
|
+
# @return Eventline::Account
|
66
|
+
def self.current_account(client)
|
67
|
+
request = Net::HTTP::Get.new("/v0/account")
|
68
|
+
response = client.call(request)
|
69
|
+
account = new
|
70
|
+
account.from_h(response)
|
71
|
+
account
|
72
|
+
end
|
73
|
+
|
74
|
+
def initialize
|
75
|
+
end
|
76
|
+
|
77
|
+
# Load account from a hash object.
|
78
|
+
#
|
79
|
+
# @raise [KeyError]
|
80
|
+
#
|
81
|
+
# @return Eventline::Account
|
82
|
+
def from_h(data)
|
83
|
+
@id = data.fetch("id")
|
84
|
+
@org_id = data.fetch("org_id")
|
85
|
+
@creation_time = data.fetch("creation_time")
|
86
|
+
@disabled = data.fetch("disabled")
|
87
|
+
@email_address = data.fetch("email_address")
|
88
|
+
@name = data["name"]
|
89
|
+
@role = data.fetch("role")
|
90
|
+
@last_login_time = data["last_login_time"]
|
91
|
+
@last_project_id = data["last_project_id"]
|
92
|
+
@settings = data.fetch("settings")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
# Copyright (c) 2021-2022 Exograd SAS.
|
2
|
+
#
|
3
|
+
# Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
# purpose with or without fee is hereby granted, provided that the above
|
5
|
+
# copyright notice and this permission notice appear in all copies.
|
6
|
+
#
|
7
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
|
15
|
+
require("net/https")
|
16
|
+
require("openssl")
|
17
|
+
require("set")
|
18
|
+
require("json")
|
19
|
+
|
20
|
+
module Eventline
|
21
|
+
class Client
|
22
|
+
class ListResponse
|
23
|
+
attr_reader(:elements, :next, :previous)
|
24
|
+
|
25
|
+
def initialize(elements, next0, previous0)
|
26
|
+
@elements = elements
|
27
|
+
|
28
|
+
@next = Pagination.new(next0.to_h)
|
29
|
+
@previous = Pagination.new(previous0.to_h)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Pagination
|
34
|
+
attr_reader(:after, :before, :sort, :size, :order)
|
35
|
+
|
36
|
+
def initialize(opts)
|
37
|
+
@after = opts["after"]
|
38
|
+
@before = opts["before"]
|
39
|
+
@sort = opts["sort"]
|
40
|
+
@size = opts["size"]
|
41
|
+
@order = opts["order"]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# @attr_reader status [Integer] The HTTP response status code.
|
46
|
+
# @attr_reader code [String] The API error code.
|
47
|
+
# @attr_reader data [String, Hash] The HTTP response body.
|
48
|
+
# @attr_reader message [String] The human readable message.
|
49
|
+
class RequestError < StandardError
|
50
|
+
attr_reader(:status, :code, :data)
|
51
|
+
|
52
|
+
# @param status [Integer]
|
53
|
+
# @param code [String]
|
54
|
+
# @param data [String,Hash]
|
55
|
+
# @param message [String]
|
56
|
+
def initialize(status, code, data, message)
|
57
|
+
super(message)
|
58
|
+
@status = status
|
59
|
+
@code = code
|
60
|
+
@data = data
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
PUBLIC_KEY_PIN_SET = Set[
|
65
|
+
"820df1ed4e14ad67d352960dcbdc0bdbe198390862ddf8395139f9a7303aee07"
|
66
|
+
].freeze
|
67
|
+
|
68
|
+
# @param project_id [String]
|
69
|
+
# @param host [String]
|
70
|
+
# @param port [Integer]
|
71
|
+
# @param token [String]
|
72
|
+
def initialize(project_id:, host: "api.eventline.net", port: 443, token: "")
|
73
|
+
store = OpenSSL::X509::Store.new
|
74
|
+
store.add_file(File.expand_path("cacert.pem", __dir__ + "/../data"))
|
75
|
+
|
76
|
+
@token = ENV.fetch("EVENTLINE_API_KEY", token.to_s)
|
77
|
+
|
78
|
+
@project_id = project_id.to_s
|
79
|
+
|
80
|
+
@mut = Mutex.new
|
81
|
+
@conn = Net::HTTP.new(host, port)
|
82
|
+
|
83
|
+
@conn.keep_alive_timeout = 30
|
84
|
+
|
85
|
+
@conn.open_timeout = 30
|
86
|
+
@conn.read_timeout = 30
|
87
|
+
@conn.write_timeout = 30
|
88
|
+
|
89
|
+
@conn.use_ssl = true
|
90
|
+
@conn.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
91
|
+
@conn.cert_store = store
|
92
|
+
@conn.verify_callback = lambda do |preverify_ok, cert_store|
|
93
|
+
return false if !preverify_ok
|
94
|
+
|
95
|
+
public_key = cert_store.chain.first.public_key.to_der
|
96
|
+
fingerprint = OpenSSL::Digest::SHA256.new(public_key).hexdigest
|
97
|
+
PUBLIC_KEY_PIN_SET.include?(fingerprint)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Execute an HTTP request on the connection.
|
102
|
+
#
|
103
|
+
# @param request [HTTPRequest] the HTTP request to execute
|
104
|
+
#
|
105
|
+
# @raise [RequestError] if the server not responds with 2xx status.
|
106
|
+
# @raise [SocketError]
|
107
|
+
# @raise [Timeout::Error]
|
108
|
+
#
|
109
|
+
# @return [String, Hash]
|
110
|
+
def call(request)
|
111
|
+
request.content_type = "application/json"
|
112
|
+
request.content_length = request.body.to_s.bytesize
|
113
|
+
|
114
|
+
request["Accept"] = "application/json"
|
115
|
+
request["User-Agent"] = "Eventline/1.0 (platform; ruby) eventline-sdk"
|
116
|
+
request["Authorization"] = "Bearer #{@token}"
|
117
|
+
request["X-Eventline-Project-Id"] = @project_id
|
118
|
+
|
119
|
+
response = @mut.synchronize do
|
120
|
+
@conn.request(request)
|
121
|
+
end
|
122
|
+
|
123
|
+
data = if response.content_type == "application/json"
|
124
|
+
begin
|
125
|
+
JSON.parse(response.body)
|
126
|
+
rescue
|
127
|
+
raise(
|
128
|
+
RequestError.new(
|
129
|
+
response.code.to_i,
|
130
|
+
"invalid_json",
|
131
|
+
response.body,
|
132
|
+
"invalid json body"
|
133
|
+
)
|
134
|
+
)
|
135
|
+
end
|
136
|
+
else
|
137
|
+
response.body
|
138
|
+
end
|
139
|
+
|
140
|
+
if response.code.to_i < 200 || response.code.to_i >= 300
|
141
|
+
if response.content_type == "application/json"
|
142
|
+
raise(
|
143
|
+
RequestError.new(
|
144
|
+
response.code.to_i,
|
145
|
+
data.fetch("code", "unknown_error"),
|
146
|
+
data.fetch("data", {}),
|
147
|
+
data.fetch("error")
|
148
|
+
)
|
149
|
+
)
|
150
|
+
else
|
151
|
+
raise(
|
152
|
+
RequestError.new(
|
153
|
+
response.code.to_i,
|
154
|
+
"invalid_json",
|
155
|
+
response.body,
|
156
|
+
"invalid json body"
|
157
|
+
)
|
158
|
+
)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
data
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# Copyright (c) 2021-2022 Exograd SAS.
|
2
|
+
#
|
3
|
+
# Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
# purpose with or without fee is hereby granted, provided that the above
|
5
|
+
# copyright notice and this permission notice appear in all copies.
|
6
|
+
#
|
7
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
|
15
|
+
require("json")
|
16
|
+
require("eventline/event")
|
17
|
+
|
18
|
+
module Eventline
|
19
|
+
class Context
|
20
|
+
attr_reader(:event, :task_parameters, :instance_id, :identities)
|
21
|
+
|
22
|
+
# Returns `true` when the function is called in an Eventline instance.
|
23
|
+
#
|
24
|
+
# @return Boolean
|
25
|
+
def self.executed_in_eventline?
|
26
|
+
ENV["EVENTLINE"].to_s.eql?("true")
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns the current project id when the function is called in an Eventline instance.
|
30
|
+
#
|
31
|
+
# @return String
|
32
|
+
def self.current_project_id
|
33
|
+
ENV["EVENTLINE_PROJECT_ID"].to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns the current project name when the function is called in an Eventline
|
37
|
+
# instance.
|
38
|
+
#
|
39
|
+
# @return String
|
40
|
+
def self.current_project_name
|
41
|
+
ENV["EVENTLINE_PROJECT_NAME"].to_s
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns the current pipeline id when the function is called in an Eventline
|
45
|
+
# instance.
|
46
|
+
#
|
47
|
+
# @return String
|
48
|
+
def self.current_pipeline_id
|
49
|
+
ENV["EVENTLINE_PIPELINE_ID"].to_s
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns the current task id when the function is called in an Eventline instance.
|
53
|
+
#
|
54
|
+
# @return String
|
55
|
+
def self.current_task_id
|
56
|
+
ENV["EVENTLINE_TASK_ID"].to_s
|
57
|
+
end
|
58
|
+
|
59
|
+
# Load and return a context object.
|
60
|
+
#
|
61
|
+
# @raise [Errno::ENOENT]
|
62
|
+
# @raise [Errno::EACCES]
|
63
|
+
# @raise [JSON::ParserError]
|
64
|
+
#
|
65
|
+
# @return Eventline::Context
|
66
|
+
def self.load
|
67
|
+
filename = ENV.fetch("EVENTLINE_CONTEXT_PATH", "/eventline/task/context")
|
68
|
+
file = IO.read(filename)
|
69
|
+
data = JSON.parse(file)
|
70
|
+
context = new
|
71
|
+
context.from_h(data)
|
72
|
+
context
|
73
|
+
end
|
74
|
+
|
75
|
+
def initialize
|
76
|
+
end
|
77
|
+
|
78
|
+
# Load context from a hash object.
|
79
|
+
#
|
80
|
+
# @raise [KeyError]
|
81
|
+
# @raise [ArgumentError]
|
82
|
+
#
|
83
|
+
# @return Eventline::Context
|
84
|
+
def from_h(data)
|
85
|
+
@event = Eventline::Event.new.from_h(data.fetch("event"))
|
86
|
+
@task_parameters = data.fetch("task_parameters")
|
87
|
+
@instance_id = Integer(data.fetch("instance_id"))
|
88
|
+
@identities = data.fetch("identities")
|
89
|
+
self
|
90
|
+
end
|
91
|
+
|
92
|
+
# Returns `true` when the pipeline is launch by an event.
|
93
|
+
#
|
94
|
+
# @return Boolean
|
95
|
+
def launch_by_event?
|
96
|
+
@event.trigger_id.nil?
|
97
|
+
end
|
98
|
+
|
99
|
+
# Returns `true` when the pipeline is launch by a command.
|
100
|
+
#
|
101
|
+
# @return Boolean
|
102
|
+
def launch_by_command?
|
103
|
+
@event.command_id.nil?
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# Copyright (c) 2021-2022 Exograd SAS.
|
2
|
+
#
|
3
|
+
# Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
# purpose with or without fee is hereby granted, provided that the above
|
5
|
+
# copyright notice and this permission notice appear in all copies.
|
6
|
+
#
|
7
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
|
15
|
+
require("eventline/client")
|
16
|
+
|
17
|
+
module Eventline
|
18
|
+
class Event
|
19
|
+
attr_accessor(:id, :org_id, :trigger_id, :command_id, :creation_time, :event, :name,
|
20
|
+
:data, :original_event_id)
|
21
|
+
|
22
|
+
# Fetch a list of events.
|
23
|
+
#
|
24
|
+
# @param [Eventline::Client] client
|
25
|
+
# @param [Hash] data
|
26
|
+
#
|
27
|
+
# @raise [Eventline::Client::RequestError]
|
28
|
+
#
|
29
|
+
# @return Eventline::Client::ListResponse
|
30
|
+
def self.list(client, data = nil)
|
31
|
+
request = Net::HTTP::Get.new("/v0/events")
|
32
|
+
response = client.call(request)
|
33
|
+
|
34
|
+
elements = response.fetch("elements", []).map do |element|
|
35
|
+
event = new
|
36
|
+
event.from_h(element)
|
37
|
+
event
|
38
|
+
end
|
39
|
+
|
40
|
+
Client::ListResponse.new(elements, response["next"], response["previous"])
|
41
|
+
end
|
42
|
+
|
43
|
+
# Fetch an event by identifier.
|
44
|
+
#
|
45
|
+
# @param [Eventline::Client] client
|
46
|
+
# @param [String] id
|
47
|
+
#
|
48
|
+
# @raise [Eventline::Client::RequestError]
|
49
|
+
#
|
50
|
+
# @return Eventline::Event
|
51
|
+
def self.retrive(client, id)
|
52
|
+
request = Net::HTTP::Get.new(File.join("/v0/events/id", id))
|
53
|
+
response = client.call(request)
|
54
|
+
event = new
|
55
|
+
event.from_h(response)
|
56
|
+
event
|
57
|
+
end
|
58
|
+
|
59
|
+
# Create a new custom event.
|
60
|
+
#
|
61
|
+
#
|
62
|
+
# @param [Eventline::Client] client
|
63
|
+
# @param [Hash] data
|
64
|
+
#
|
65
|
+
# @raise [Eventline::Client::RequestError]
|
66
|
+
#
|
67
|
+
# @return [Eventline::Event]
|
68
|
+
def self.create(client, data)
|
69
|
+
request = Net::HTTP::Post.new("/v0/events")
|
70
|
+
request.body = JSON.dump(data)
|
71
|
+
response = client.call(request)
|
72
|
+
|
73
|
+
response.map do |element|
|
74
|
+
event = new
|
75
|
+
event.from_h(element)
|
76
|
+
event
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Replay an existing event.
|
81
|
+
#
|
82
|
+
# @param [Eventline::Client] client
|
83
|
+
# @param [String] id
|
84
|
+
#
|
85
|
+
# @raise [Eventline::Client::RequestError]
|
86
|
+
#
|
87
|
+
# @return Eventline::Event
|
88
|
+
def self.replay(client, id)
|
89
|
+
request = Net::HTTP::Post.new(File.join("/v0/events", id, "replay"))
|
90
|
+
response = client.call(request)
|
91
|
+
event = new
|
92
|
+
event.from_h(response)
|
93
|
+
event
|
94
|
+
end
|
95
|
+
|
96
|
+
def initialize
|
97
|
+
end
|
98
|
+
|
99
|
+
# Load event from a hash object.
|
100
|
+
#
|
101
|
+
# @raise [KeyError]
|
102
|
+
#
|
103
|
+
# @return Eventline::Event
|
104
|
+
def from_h(data)
|
105
|
+
@id = data.fetch("id")
|
106
|
+
@org_id = data.fetch("org_id")
|
107
|
+
@trigger_id = data.fetch("trigger_id", nil)
|
108
|
+
@command_id = data.fetch("command_id", nil)
|
109
|
+
@creation_time = data.fetch("creation_time")
|
110
|
+
@event_time = data.fetch("event_time")
|
111
|
+
@name = data.fetch("name")
|
112
|
+
@data = data.fetch("data")
|
113
|
+
@original_event_id = data.fetch("original_event_id", nil)
|
114
|
+
self
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Copyright (c) 2021-2022 Exograd SAS.
|
2
|
+
#
|
3
|
+
# Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
# purpose with or without fee is hereby granted, provided that the above
|
5
|
+
# copyright notice and this permission notice appear in all copies.
|
6
|
+
#
|
7
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
|
15
|
+
require("eventline/client")
|
16
|
+
|
17
|
+
module Eventline
|
18
|
+
class Organization
|
19
|
+
attr_accessor(:id, :name, :address, :postal_code, :city, :country,
|
20
|
+
:contact_email_address, :non_essential_mail_opt_in, :vat_id_number)
|
21
|
+
|
22
|
+
# Fetch the organization associated with the credentials currently used by the client.
|
23
|
+
#
|
24
|
+
# @param [Eventline::Client] client
|
25
|
+
#
|
26
|
+
# @raise [Eventline::Client::RequestError]
|
27
|
+
#
|
28
|
+
# @return Eventline::Organization
|
29
|
+
def self.retrieve(client)
|
30
|
+
request = Net::HTTP::Get.new("/v0/org")
|
31
|
+
response = client.call(request)
|
32
|
+
organization = new
|
33
|
+
organization.from_h(response)
|
34
|
+
organization
|
35
|
+
end
|
36
|
+
|
37
|
+
def initialize
|
38
|
+
end
|
39
|
+
|
40
|
+
# Load organization from a hash object.
|
41
|
+
#
|
42
|
+
# @raise [KeyError]
|
43
|
+
#
|
44
|
+
# @return Eventline::Organization
|
45
|
+
def from_h(data)
|
46
|
+
@id = data.fetch("id")
|
47
|
+
@name = data.fetch("name")
|
48
|
+
@address = data["address"]
|
49
|
+
@postal_code = data["postal_code"]
|
50
|
+
@city = data["city"]
|
51
|
+
@country = data["country"]
|
52
|
+
@contact_email_address = data.fetch("contact_email_address")
|
53
|
+
@non_essential_mail_opt_in = data.fetch("non_essential_mail_opt_in")
|
54
|
+
@vat_id_number = data["vat_id_number"]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Copyright (c) 2021-2022 Exograd SAS.
|
2
|
+
#
|
3
|
+
# Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
# purpose with or without fee is hereby granted, provided that the above
|
5
|
+
# copyright notice and this permission notice appear in all copies.
|
6
|
+
#
|
7
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
|
15
|
+
module Eventline
|
16
|
+
VERSION = "0.1.0"
|
17
|
+
end
|
data/lib/eventline.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "eventline/version"
|
4
|
+
require "eventline/client"
|
5
|
+
require "eventline/context"
|
6
|
+
require "eventline/event"
|
7
|
+
require "eventline/organization"
|
8
|
+
require "eventline/account"
|
9
|
+
|
10
|
+
module Eventline
|
11
|
+
class Error < StandardError; end
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eventline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Exograd SAS
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-04-20 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Eventline is a scheduling platform where you can define and run custom
|
14
|
+
tasks in a safe environment.
|
15
|
+
email:
|
16
|
+
- support@exograd.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/eventline.rb
|
22
|
+
- lib/eventline/account.rb
|
23
|
+
- lib/eventline/client.rb
|
24
|
+
- lib/eventline/context.rb
|
25
|
+
- lib/eventline/event.rb
|
26
|
+
- lib/eventline/organization.rb
|
27
|
+
- lib/eventline/version.rb
|
28
|
+
homepage: https://docs.eventline.net
|
29
|
+
licenses: []
|
30
|
+
metadata:
|
31
|
+
bug_tracker_uri: https://github.com/exograd/rb-eventline/issues
|
32
|
+
changelog_uri: https://github.com/exograd/rb-eventline/blob/master/CHANGELOG.md
|
33
|
+
github_repo: ssh://github.com/exograd/rb-eventline
|
34
|
+
homepage_uri: https://docs.eventline.net
|
35
|
+
source_code_uri: https://github.com/exograd/rb-eventline
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 2.6.0
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubygems_version: 3.1.2
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: Eventline Ruby SDK.
|
55
|
+
test_files: []
|