ruby-magicwrite 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -1
- data/Gemfile.lock +1 -1
- data/lib/magicwrite/agents.rb +14 -10
- data/lib/magicwrite/client.rb +19 -11
- data/lib/magicwrite/companies.rb +9 -5
- data/lib/magicwrite/completions.rb +10 -6
- data/lib/magicwrite/http.rb +4 -4
- data/lib/magicwrite/ingestions.rb +10 -6
- data/lib/magicwrite/memberships.rb +8 -4
- data/lib/magicwrite/version.rb +1 -1
- data/lib/magicwrite.rb +8 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe492bf84e88d0fac86ee681671ab724a7247d37403301fcc6b2d24c5db23fb0
|
4
|
+
data.tar.gz: 67460bd0593a9e4b7503e6e048b42d0927631c62e784951056d629edc1e99666
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6a1b30d5c33d06fcd20eb1ce55e76326fc3889852824b331cc4da7ba8f2a65f1186cdbf44aff6180ba66afc6c2695a329d45ae2dc8edd85f1d141e3ec5f14a1
|
7
|
+
data.tar.gz: 564f7069e45f14f0370c634c65296d915032e9ac1a6c393724ef1aaa97187c85b222680ff6ab4a1909a0a7fd0753fe571114c0e0c4fb8f378f5c2d310d350b21
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [0.1.5] - 2023-08-22
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- More specs to cover more implementations
|
13
|
+
- Refactor client and methods to use client in initalization
|
14
|
+
- include HTTP instead of extend for Client class
|
15
|
+
|
16
|
+
## [0.1.4] - 2023-08-22
|
17
|
+
|
18
|
+
### Added
|
19
|
+
|
20
|
+
- Memberships endpoints to MagicWrite client
|
21
|
+
|
22
|
+
|
23
|
+
## [0.1.3] - 2023-08-21
|
24
|
+
|
25
|
+
### Added
|
26
|
+
|
27
|
+
- General error classes by HTTP responses
|
28
|
+
- Error handler to parse the result
|
29
|
+
|
30
|
+
|
31
|
+
### Changed
|
32
|
+
|
33
|
+
- README
|
34
|
+
|
35
|
+
|
8
36
|
## [0.1.2] - 2023-06-21
|
9
37
|
|
10
38
|
### Added
|
@@ -24,6 +52,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
24
52
|
|
25
53
|
### Added
|
26
54
|
|
27
|
-
-
|
55
|
+
- Initialize repository.
|
28
56
|
- Add MagicWrite::Client to connect to MagicWrite API using user tokens.
|
57
|
+
* Completions
|
58
|
+
* Agents
|
59
|
+
* Companies
|
60
|
+
* Ingestions
|
61
|
+
* Session
|
29
62
|
|
data/Gemfile.lock
CHANGED
data/lib/magicwrite/agents.rb
CHANGED
@@ -1,39 +1,43 @@
|
|
1
1
|
module MagicWrite
|
2
2
|
class Agents
|
3
|
-
def initialize(
|
4
|
-
|
3
|
+
def initialize(client:)
|
4
|
+
@client = client
|
5
5
|
end
|
6
6
|
|
7
7
|
def list(parameters: {})
|
8
|
-
|
8
|
+
client.get(path: '/agents', parameters: parameters)
|
9
9
|
end
|
10
10
|
|
11
11
|
def create(parameters: {})
|
12
|
-
|
12
|
+
client.json_post(path: '/agents', parameters: parameters)
|
13
13
|
end
|
14
14
|
|
15
15
|
def retrieve(id:)
|
16
|
-
|
16
|
+
client.get(path: "/agents/#{id}")
|
17
17
|
end
|
18
18
|
|
19
19
|
def update(id:, parameters: {})
|
20
|
-
|
20
|
+
client.json_put(path: "/agents/#{id}", parameters: parameters)
|
21
21
|
end
|
22
22
|
|
23
23
|
def delete(id:)
|
24
|
-
|
24
|
+
client.delete(path: "/agents/#{id}")
|
25
25
|
end
|
26
26
|
|
27
27
|
def public_list(company_id:, parameters: {})
|
28
|
-
|
28
|
+
client.get(path: "/agents/#{company_id}", parameters: parameters)
|
29
29
|
end
|
30
30
|
|
31
31
|
def public_retrieve(company_id:, agent_id:)
|
32
|
-
|
32
|
+
client.get(path: "/agents/#{company_id}/#{agent_id}")
|
33
33
|
end
|
34
34
|
|
35
35
|
def public_create(company_id:, agent_id:, parameters: {})
|
36
|
-
|
36
|
+
client.json_post(path: "/agents/#{company_id}/#{agent_id}", parameters: parameters)
|
37
37
|
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
attr_reader :client
|
38
42
|
end
|
39
43
|
end
|
data/lib/magicwrite/client.rb
CHANGED
@@ -1,35 +1,43 @@
|
|
1
1
|
module MagicWrite
|
2
2
|
class Client
|
3
|
-
|
3
|
+
include MagicWrite::HTTP
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
CONFIG_KEYS = %i[
|
6
|
+
access_token
|
7
|
+
uri_base
|
8
|
+
request_timeout
|
9
|
+
extra_headers
|
10
|
+
].freeze
|
11
|
+
attr_reader(*CONFIG_KEYS)
|
12
|
+
|
13
|
+
def initialize(config = {})
|
14
|
+
CONFIG_KEYS.each do |key|
|
15
|
+
instance_variable_set("@#{key}", config[key] || MagicWrite.configuration.send(key))
|
16
|
+
end
|
9
17
|
end
|
10
18
|
|
11
19
|
def agents
|
12
|
-
@agents ||= MagicWrite::Agents.new
|
20
|
+
@agents ||= MagicWrite::Agents.new(client: self)
|
13
21
|
end
|
14
22
|
|
15
23
|
def companies
|
16
|
-
@companies ||= MagicWrite::Companies.new
|
24
|
+
@companies ||= MagicWrite::Companies.new(client: self)
|
17
25
|
end
|
18
26
|
|
19
27
|
def completions
|
20
|
-
@completions ||= MagicWrite::Completions.new
|
28
|
+
@completions ||= MagicWrite::Completions.new(client: self)
|
21
29
|
end
|
22
30
|
|
23
31
|
def ingestions
|
24
|
-
@ingestions ||= MagicWrite::Ingestions.new
|
32
|
+
@ingestions ||= MagicWrite::Ingestions.new(client: self)
|
25
33
|
end
|
26
34
|
|
27
35
|
def memberships
|
28
|
-
@memberships ||= MagicWrite::Memberships.new
|
36
|
+
@memberships ||= MagicWrite::Memberships.new(client: self)
|
29
37
|
end
|
30
38
|
|
31
39
|
def session
|
32
|
-
|
40
|
+
get(path: '/session')
|
33
41
|
end
|
34
42
|
end
|
35
43
|
end
|
data/lib/magicwrite/companies.rb
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
module MagicWrite
|
2
2
|
class Companies
|
3
|
-
def initialize(
|
4
|
-
|
3
|
+
def initialize(client:)
|
4
|
+
@client = client
|
5
5
|
end
|
6
6
|
|
7
7
|
def create(parameters: {})
|
8
|
-
|
8
|
+
client.json_post(path: '/companies', parameters: parameters)
|
9
9
|
end
|
10
10
|
|
11
11
|
def retrieve
|
12
|
-
|
12
|
+
client.get(path: '/companies/current')
|
13
13
|
end
|
14
14
|
|
15
15
|
def update(parameters: {})
|
16
|
-
|
16
|
+
client.json_put(path: '/companies/current', parameters: parameters)
|
17
17
|
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :client
|
18
22
|
end
|
19
23
|
end
|
@@ -1,23 +1,27 @@
|
|
1
1
|
module MagicWrite
|
2
2
|
class Completions
|
3
|
-
def initialize(
|
4
|
-
|
3
|
+
def initialize(client:)
|
4
|
+
@client = client
|
5
5
|
end
|
6
6
|
|
7
7
|
def execute(parameters: {})
|
8
|
-
|
8
|
+
client.json_post(path: '/completions', parameters: parameters)
|
9
9
|
end
|
10
10
|
|
11
11
|
def retrieve(id:, parameters: {})
|
12
|
-
|
12
|
+
client.get(path: "/completions/#{id}", parameters: parameters)
|
13
13
|
end
|
14
14
|
|
15
15
|
def create(id:, parameters: {})
|
16
|
-
|
16
|
+
client.json_post(path: "/completions/#{id}", parameters: parameters)
|
17
17
|
end
|
18
18
|
|
19
19
|
def delete(id:, completion_id:)
|
20
|
-
|
20
|
+
client.delete(path: "/completions/#{id}/#{completion_id}")
|
21
21
|
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :client
|
22
26
|
end
|
23
27
|
end
|
data/lib/magicwrite/http.rb
CHANGED
@@ -82,20 +82,20 @@ module MagicWrite
|
|
82
82
|
|
83
83
|
def conn(multipart: false)
|
84
84
|
Faraday.new do |faraday|
|
85
|
-
faraday.options[:timeout] =
|
85
|
+
faraday.options[:timeout] = @request_timeout
|
86
86
|
faraday.request(:multipart) if multipart
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
def uri(path:)
|
91
|
-
File.join(
|
91
|
+
File.join(@uri_base, path)
|
92
92
|
end
|
93
93
|
|
94
94
|
def headers
|
95
95
|
{
|
96
96
|
'Content-Type' => 'application/json',
|
97
|
-
'Authorization' => "Bearer #{
|
98
|
-
}
|
97
|
+
'Authorization' => "Bearer #{@access_token}"
|
98
|
+
}.merge(@extra_headers || {})
|
99
99
|
end
|
100
100
|
|
101
101
|
def multipart_parameters(parameters)
|
@@ -1,23 +1,27 @@
|
|
1
1
|
module MagicWrite
|
2
2
|
class Ingestions
|
3
|
-
def initialize(
|
4
|
-
|
3
|
+
def initialize(client:)
|
4
|
+
@client = client
|
5
5
|
end
|
6
6
|
|
7
7
|
def list(parameters: {})
|
8
|
-
|
8
|
+
client.get(path: '/ingestions', parameters: parameters)
|
9
9
|
end
|
10
10
|
|
11
11
|
def create(parameters: {})
|
12
|
-
|
12
|
+
client.json_post(path: '/ingestions', parameters: parameters)
|
13
13
|
end
|
14
14
|
|
15
15
|
def retrieve(id:)
|
16
|
-
|
16
|
+
client.get(path: "/ingestions/#{id}")
|
17
17
|
end
|
18
18
|
|
19
19
|
def delete(id:)
|
20
|
-
|
20
|
+
client.delete(path: "/ingestions/#{id}")
|
21
21
|
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :client
|
22
26
|
end
|
23
27
|
end
|
@@ -1,15 +1,19 @@
|
|
1
1
|
module MagicWrite
|
2
2
|
class Memberships
|
3
|
-
def initialize(
|
4
|
-
|
3
|
+
def initialize(client:)
|
4
|
+
@client = client
|
5
5
|
end
|
6
6
|
|
7
7
|
def user
|
8
|
-
|
8
|
+
client.get(path: '/memberships/user')
|
9
9
|
end
|
10
10
|
|
11
11
|
def company
|
12
|
-
|
12
|
+
client.get(path: '/memberships/company')
|
13
13
|
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
attr_reader :client
|
14
18
|
end
|
15
19
|
end
|
data/lib/magicwrite/version.rb
CHANGED
data/lib/magicwrite.rb
CHANGED
@@ -17,7 +17,7 @@ module MagicWrite
|
|
17
17
|
|
18
18
|
class Configuration
|
19
19
|
attr_writer :access_token
|
20
|
-
attr_accessor :uri_base, :request_timeout
|
20
|
+
attr_accessor :uri_base, :request_timeout, :extra_headers
|
21
21
|
|
22
22
|
DEFAULT_URI_BASE = 'https://api.magicwrite.ai/rest/'.freeze
|
23
23
|
DEFAULT_REQUEST_TIMEOUT = 120
|
@@ -26,6 +26,7 @@ module MagicWrite
|
|
26
26
|
@access_token = nil
|
27
27
|
@uri_base = DEFAULT_URI_BASE
|
28
28
|
@request_timeout = DEFAULT_REQUEST_TIMEOUT
|
29
|
+
@extra_headers = nil
|
29
30
|
end
|
30
31
|
|
31
32
|
def access_token
|
@@ -38,13 +39,13 @@ module MagicWrite
|
|
38
39
|
|
39
40
|
class << self
|
40
41
|
attr_writer :configuration
|
41
|
-
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
def configuration
|
44
|
+
@configuration ||= MagicWrite::Configuration.new
|
45
|
+
end
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
def configure
|
48
|
+
yield(configuration)
|
49
|
+
end
|
49
50
|
end
|
50
51
|
end
|