osuny_api 0.2.1 → 0.2.3
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/Gemfile.lock +1 -1
 - data/README.md +2 -2
 - data/lib/osuny_api/client.rb +38 -36
 - data/lib/osuny_api/communication/website/page.rb +12 -0
 - data/lib/osuny_api/communication/website/post.rb +8 -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 +4 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 59f1b8d157560352eddae3b4b0789d18f1635e5744802a717374aba06ea0c728
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e15e5b411ea1e5ba835972db77c489e4253c7871d87543c4be219eb4809c6f39
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 27ee12f06c28e81ec2896ade22829d1e844bc537cf230d75b00dfa37b8015721ef546554495eb79b96047cfc41c7059eb3aa8a6bf86cb78774d9847628ec71df
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 757db895eec60bc3d015f3ef60fdafc865e07ea0f12601a31f2ee7cffea937d692429afb12f30c4d67f13e3f6458e9e178add7c9904be447f349642311db2a4b
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -16,14 +16,14 @@ If bundler is not being used to manage dependencies, install the gem by executin 
     | 
|
| 
       16 
16 
     | 
    
         
             
            osuny = OsunyApi.new  host: 'https://instance.osuny.org',
         
     | 
| 
       17 
17 
     | 
    
         
             
                                  token: 'real_token'
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
            migration_identifier = "identifiant-unique"
         
     | 
| 
       20 
19 
     | 
    
         
             
            post = {
         
     | 
| 
      
 20 
     | 
    
         
            +
              migration_identifier: "identifiant-unique"
         
     | 
| 
       21 
21 
     | 
    
         
             
              title: 'Titre importé'
         
     | 
| 
       22 
22 
     | 
    
         
             
            }
         
     | 
| 
       23 
23 
     | 
    
         
             
            osuny.communication
         
     | 
| 
       24 
24 
     | 
    
         
             
                 .website('real_website_id')
         
     | 
| 
       25 
25 
     | 
    
         
             
                 .post
         
     | 
| 
       26 
     | 
    
         
            -
                 .import( 
     | 
| 
      
 26 
     | 
    
         
            +
                 .import(post)
         
     | 
| 
       27 
27 
     | 
    
         
             
            ```
         
     | 
| 
       28 
28 
     | 
    
         
             
            ## License
         
     | 
| 
       29 
29 
     | 
    
         | 
    
        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,12 @@ 
     | 
|
| 
       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 
     | 
    
         
            -
                  post: data
         
     | 
| 
       11 
     | 
    
         
            -
                }
         
     | 
| 
      
 8 
     | 
    
         
            +
                def import(post)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  client.post "#{full_path}import", { post: post }
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
       12 
11 
     | 
    
         
             
              end
         
     | 
| 
       13 
12 
     | 
    
         
             
            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.3
         
     | 
| 
       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- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2023-10-18 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: httparty
         
     | 
| 
         @@ -42,6 +42,7 @@ files: 
     | 
|
| 
       42 
42 
     | 
    
         
             
            - lib/osuny_api/client.rb
         
     | 
| 
       43 
43 
     | 
    
         
             
            - lib/osuny_api/communication.rb
         
     | 
| 
       44 
44 
     | 
    
         
             
            - lib/osuny_api/communication/website.rb
         
     | 
| 
      
 45 
     | 
    
         
            +
            - lib/osuny_api/communication/website/page.rb
         
     | 
| 
       45 
46 
     | 
    
         
             
            - lib/osuny_api/communication/website/post.rb
         
     | 
| 
       46 
47 
     | 
    
         
             
            - lib/osuny_api/error.rb
         
     | 
| 
       47 
48 
     | 
    
         
             
            - lib/osuny_api/resource.rb
         
     | 
| 
         @@ -68,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       68 
69 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       69 
70 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       70 
71 
     | 
    
         
             
            requirements: []
         
     | 
| 
       71 
     | 
    
         
            -
            rubygems_version: 3.4. 
     | 
| 
      
 72 
     | 
    
         
            +
            rubygems_version: 3.4.6
         
     | 
| 
       72 
73 
     | 
    
         
             
            signing_key:
         
     | 
| 
       73 
74 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       74 
75 
     | 
    
         
             
            summary: Gem Ruby pour l'API Osuny
         
     |