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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ad40e0aa413a62e81133fb379bea4c75f21c2ed05c623675e6dcb64d7560fd8
4
- data.tar.gz: ab6da0f51fed17d500e0aad44efe3db305c44416656fb702d653aba3503f0fff
3
+ metadata.gz: aa384d23e319961d074a82202f346b2d6dc652f98076c6fb2a07d60b913f00af
4
+ data.tar.gz: 466248d32f23e6c958721981ef62e22dec07a56cd1024da3229a66274c150dd5
5
5
  SHA512:
6
- metadata.gz: dc3481e56415c90ac97a1489369258a0a0ed3333a454e2df42826008fd98d1eb99fd6057a870f396f9178ed648efd3f1e5503da9396603370643edfa1209410d
7
- data.tar.gz: 9b0f2d55efac94ace1c72c9ae36951de5084f178c60c94d60a40d0702a730a0262582dca0c0c446eaea746a77a8d2bdcf360c5573922c8a02d818b8b98b779a9
6
+ metadata.gz: 90966cd42594866d5bd2d6e8857db3d9b571e8ae66a998fcc79dd896e2179e07513eb9ddfa1cbe5e8159cddd01558e9988b2dfc791eb50002b53b4c2fdc73de8
7
+ data.tar.gz: 4ee584ea2031804795ed23d7c8be4cc861b4187ddd14b8a20fa3ab87c5d7dfceaaddb9998b9250b75741690535f4acbff64576e2fa441ead0f76c88feb64d5eb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- osuny_api (0.2.1)
4
+ osuny_api (0.2.2)
5
5
  httparty
6
6
 
7
7
  GEM
@@ -1,39 +1,41 @@
1
1
  require 'httparty'
2
2
 
3
- class OsunyApi::Client
4
- attr_reader :host, :token
5
-
6
- LOG_GREEN = 32
7
- LOG_RED = 31
8
-
9
- def initialize(options = {})
10
- @host = options[:host]
11
- @token = options[:token]
12
- end
13
-
14
- def communication
15
- @communication ||= OsunyApi::Communication.new(
16
- client: self,
17
- parent: OsunyApi::Resource.new(client: self)
18
- )
19
- end
20
-
21
- def post(url, body = {})
22
- log "[POST] #{url}", LOG_GREEN
23
- response = HTTParty.post url,
24
- body: body,
25
- headers: headers
26
- log response.code
27
- end
28
-
29
- protected
30
-
31
- def headers
32
- { "X-Osuny-Token": token }
33
- end
34
-
35
- def log(string, color = nil)
36
- puts color.nil? ? string
37
- : "\e[#{color}m#{string}\e[0m"
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
- class OsunyApi::Communication::Website::Post < OsunyApi::Resource
1
+ module OsunyApi
2
+ class Communication::Website::Post < Resource
2
3
 
3
- def path
4
- 'posts/'
5
- end
4
+ def path
5
+ 'posts/'
6
+ end
6
7
 
7
- def import(migration_identifier, data)
8
- client.post "#{full_path}import", {
9
- migration_identifier: migration_identifier,
10
- post: data
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
- class OsunyApi::Communication::Website < OsunyApi::Resource
2
- attr_accessor :id
1
+ module OsunyApi
2
+ class Communication::Website < Resource
3
+ attr_accessor :id
3
4
 
4
- def path
5
- id.nil? ? "websites/"
6
- : "websites/#{id}/"
7
- end
5
+ def path
6
+ id.nil? ? "websites/"
7
+ : "websites/#{id}/"
8
+ end
8
9
 
9
- def post
10
- @post ||= Post.new(client: client, parent: self)
10
+ def post
11
+ @post ||= Post.new(client: client, parent: self)
12
+ end
11
13
  end
12
14
  end
@@ -1,11 +1,13 @@
1
- class OsunyApi::Communication < OsunyApi::Resource
2
- def path
3
- 'communication/'
4
- end
1
+ module OsunyApi
2
+ class Communication < Resource
3
+ def path
4
+ 'communication/'
5
+ end
5
6
 
6
- def website(id = nil)
7
- @website ||= Website.new(client: client, parent: self)
8
- @website.id = id
9
- @website
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
@@ -1,2 +1,4 @@
1
- class OsunyApi::Error < StandardError
2
- end
1
+ module OsunyApi
2
+ class Error < StandardError
3
+ end
4
+ end
@@ -1,18 +1,20 @@
1
- class OsunyApi::Resource
2
- attr_reader :parent, :client
1
+ module OsunyApi
2
+ class Resource
3
+ attr_reader :parent, :client
3
4
 
4
- def initialize(options = {})
5
- @client = OsunyApi::Client.new options if options.has_key? :token
6
- @parent = options[:parent] if options.has_key? :parent
7
- @client = options[:client] if options.has_key? :client
8
- end
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
- def path
11
- "#{client.host}/api/osuny/"
12
- end
11
+ def path
12
+ "#{client.host}/api/osuny/"
13
+ end
13
14
 
14
- def full_path
15
- parent.nil? ? "#{path}"
16
- : "#{parent.full_path}#{path}"
15
+ def full_path
16
+ parent.nil? ? "#{path}"
17
+ : "#{parent.full_path}#{path}"
18
+ end
17
19
  end
18
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OsunyApi
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
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.1
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-25 00:00:00.000000000 Z
12
+ date: 2023-09-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty