osuny_api 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/osuny_api/client.rb +38 -36
- data/lib/osuny_api/communication/website/post.rb +11 -9
- data/lib/osuny_api/communication/website.rb +10 -8
- data/lib/osuny_api/communication.rb +10 -8
- data/lib/osuny_api/error.rb +4 -2
- data/lib/osuny_api/resource.rb +15 -13
- data/lib/osuny_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa384d23e319961d074a82202f346b2d6dc652f98076c6fb2a07d60b913f00af
|
4
|
+
data.tar.gz: 466248d32f23e6c958721981ef62e22dec07a56cd1024da3229a66274c150dd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90966cd42594866d5bd2d6e8857db3d9b571e8ae66a998fcc79dd896e2179e07513eb9ddfa1cbe5e8159cddd01558e9988b2dfc791eb50002b53b4c2fdc73de8
|
7
|
+
data.tar.gz: 4ee584ea2031804795ed23d7c8be4cc861b4187ddd14b8a20fa3ab87c5d7dfceaaddb9998b9250b75741690535f4acbff64576e2fa441ead0f76c88feb64d5eb
|
data/Gemfile.lock
CHANGED
data/lib/osuny_api/client.rb
CHANGED
@@ -1,39 +1,41 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
3
|
+
module OsunyApi
|
4
|
+
class Client
|
5
|
+
attr_reader :host, :token
|
6
|
+
|
7
|
+
LOG_GREEN = 32
|
8
|
+
LOG_RED = 31
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
@host = options[:host]
|
12
|
+
@token = options[:token]
|
13
|
+
end
|
14
|
+
|
15
|
+
def communication
|
16
|
+
@communication ||= OsunyApi::Communication.new(
|
17
|
+
client: self,
|
18
|
+
parent: OsunyApi::Resource.new(client: self)
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def post(url, body = {})
|
23
|
+
log "[POST] #{url}", LOG_GREEN
|
24
|
+
response = HTTParty.post url,
|
25
|
+
body: body,
|
26
|
+
headers: headers
|
27
|
+
log response.code
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
|
32
|
+
def headers
|
33
|
+
{ "X-Osuny-Token": token }
|
34
|
+
end
|
35
|
+
|
36
|
+
def log(string, color = nil)
|
37
|
+
puts color.nil? ? string
|
38
|
+
: "\e[#{color}m#{string}\e[0m"
|
39
|
+
end
|
38
40
|
end
|
39
|
-
end
|
41
|
+
end
|
@@ -1,13 +1,15 @@
|
|
1
|
-
|
1
|
+
module OsunyApi
|
2
|
+
class Communication::Website::Post < Resource
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
def path
|
5
|
+
'posts/'
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def import(migration_identifier, data)
|
9
|
+
client.post "#{full_path}import", {
|
10
|
+
migration_identifier: migration_identifier,
|
11
|
+
post: data
|
12
|
+
}
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module OsunyApi
|
2
|
+
class Communication::Website < Resource
|
3
|
+
attr_accessor :id
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
def path
|
6
|
+
id.nil? ? "websites/"
|
7
|
+
: "websites/#{id}/"
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
def post
|
11
|
+
@post ||= Post.new(client: client, parent: self)
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
@@ -1,11 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module OsunyApi
|
2
|
+
class Communication < Resource
|
3
|
+
def path
|
4
|
+
'communication/'
|
5
|
+
end
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
def website(id = nil)
|
8
|
+
@website ||= Website.new(client: client, parent: self)
|
9
|
+
@website.id = id
|
10
|
+
@website
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
data/lib/osuny_api/error.rb
CHANGED
data/lib/osuny_api/resource.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module OsunyApi
|
2
|
+
class Resource
|
3
|
+
attr_reader :parent, :client
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def initialize(options = {})
|
6
|
+
@client = OsunyApi::Client.new options if options.has_key? :token
|
7
|
+
@parent = options[:parent] if options.has_key? :parent
|
8
|
+
@client = options[:client] if options.has_key? :client
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def path
|
12
|
+
"#{client.host}/api/osuny/"
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def full_path
|
16
|
+
parent.nil? ? "#{path}"
|
17
|
+
: "#{parent.full_path}#{path}"
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
data/lib/osuny_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osuny_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arnaud Levy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-09-
|
12
|
+
date: 2023-09-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|