Dendreo 1.0.1 → 1.0.2
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/Dendreo-1.0.0.gem +0 -0
 - data/Dendreo-1.0.1.gem +0 -0
 - data/Gemfile +2 -0
 - data/README.md +28 -5
 - data/dendreo.gemspec +1 -0
 - data/lib/dendreo/version.rb +1 -1
 - data/lib/dendreo.rb +16 -17
 - metadata +18 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: be5be5e5e6ceb74626673f5a5a3fb76a3b34611f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 92e9cfbbee2d84f649753ae66bcb313064b22ed4
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ffee2de89031124dbbb9af5917a5691f3c5d70d4f64f0967eeb8bc34447e46f8697972a16e512d8645fc271a1a329161276ed434048d344d6e15fd3e152066e1
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: eb2400411556691be6f9f1ec837ed94b3d577aa51f33c7fc20a7f8895695d4313871909c5e72982db78b23819e6f36c8834562aa686665cec5834f2bd6da5908
         
     | 
    
        data/Dendreo-1.0.0.gem
    ADDED
    
    | 
         Binary file 
     | 
    
        data/Dendreo-1.0.1.gem
    ADDED
    
    | 
         Binary file 
     | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ Gem pour l'API du CRM Dendreo. 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            ## Installation
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
            Ajoutez cette à votre Gemfile:
         
     | 
| 
      
 8 
     | 
    
         
            +
            Ajoutez cette ligne à votre Gemfile:
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            ```ruby
         
     | 
| 
       11 
11 
     | 
    
         
             
            gem 'dendreo'
         
     | 
| 
         @@ -15,7 +15,7 @@ Bien entendu: 
     | 
|
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
                $ bundle
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            Ou installez  
     | 
| 
      
 18 
     | 
    
         
            +
            Ou installez la gem vous-même:
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                $ gem install dendreo
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
         @@ -43,6 +43,25 @@ Exemple: 
     | 
|
| 
       43 
43 
     | 
    
         | 
| 
       44 
44 
     | 
    
         
             
            Il faut donc piocher le nom de la ressource tel quel est dans l'url de la requête API.
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
      
 46 
     | 
    
         
            +
            -Catégories de module.         => "categories_module"
         
     | 
| 
      
 47 
     | 
    
         
            +
            -Catégories de produits        => "categories_produit"
         
     | 
| 
      
 48 
     | 
    
         
            +
            -Modules/Produits              => "modules"
         
     | 
| 
      
 49 
     | 
    
         
            +
            -Formateurs                    => "formateurs"
         
     | 
| 
      
 50 
     | 
    
         
            +
            -Entreprises                   => "entreprises"
         
     | 
| 
      
 51 
     | 
    
         
            +
            -Contacts                      => "contacts"
         
     | 
| 
      
 52 
     | 
    
         
            +
            -Particuliers                  => "contacts" avec la variable "particulier" = 1 sinon ajout d'un contact
         
     | 
| 
      
 53 
     | 
    
         
            +
            -Participants                  => "participants"
         
     | 
| 
      
 54 
     | 
    
         
            +
            -Etapes                        => "etapes"
         
     | 
| 
      
 55 
     | 
    
         
            +
            -Centres de formation          => "centres_de_formation"
         
     | 
| 
      
 56 
     | 
    
         
            +
            -Salles de formation           => "salles_de_formation"
         
     | 
| 
      
 57 
     | 
    
         
            +
            -Factures                      => "factures"
         
     | 
| 
      
 58 
     | 
    
         
            +
            -Actions de formation          => "actions_de_formation"
         
     | 
| 
      
 59 
     | 
    
         
            +
            -Créneaux                      => "creneaux"
         
     | 
| 
      
 60 
     | 
    
         
            +
            -Inscription d'un participant  => "laps"
         
     | 
| 
      
 61 
     | 
    
         
            +
            -Programmation d'un module     => "lams"
         
     | 
| 
      
 62 
     | 
    
         
            +
            -Mails                         => "emails"
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
       46 
65 
     | 
    
         
             
            Pour les participants ( GET https://pro.dendreo.com/demo/api/participants.php?)
         
     | 
| 
       47 
66 
     | 
    
         | 
| 
       48 
67 
     | 
    
         
             
            ```ruby
         
     | 
| 
         @@ -65,15 +84,19 @@ Attention, pour modifier un participant déjà existant, il vous suffit de rempl 
     | 
|
| 
       65 
84 
     | 
    
         | 
| 
       66 
85 
     | 
    
         
             
            Je porte votre attention sur le fait que si vous modifiez un utilisateur il faudra re-rentrer la totalité des données, même si elles étaient déjà existantes auparavant, sinon il ne les gardera pas. Vous pouvez donc utiliser la méthode get avec l'id en question pour récupérer les informations avant de faire vôtre modification.
         
     | 
| 
       67 
86 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
            L'API est faite comme cela 
     | 
| 
      
 87 
     | 
    
         
            +
            L'API est faite comme cela. Ceci n'est pas encore spécifié dans la documentation.
         
     | 
| 
       69 
88 
     | 
    
         
             
            Faites appel au support dendreo pour plus d'informations, ils sont très réactifs equipe@dendreo.com .
         
     | 
| 
       70 
89 
     | 
    
         | 
| 
       71 
90 
     | 
    
         
             
            ```ruby
         
     | 
| 
       72 
91 
     | 
    
         
             
              # Créer un participant
         
     | 
| 
       73 
92 
     | 
    
         
             
              dendreo.participants(method: "post", datas: {nom: "nouveau nom", prenom: "toto", civilite: "M.", email: "toto@gmail.com", id_add: 2})
         
     | 
| 
       74 
93 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
              # Modifier un participant existant
         
     | 
| 
       76 
     | 
    
         
            -
               
     | 
| 
      
 94 
     | 
    
         
            +
              # Modifier un participant existant (Attention, bien remplacer "id" par "id_participant" et ajouter un "id_add" pour
         
     | 
| 
      
 95 
     | 
    
         
            +
              # s'identifier en admin sur la mise à jour.)
         
     | 
| 
      
 96 
     | 
    
         
            +
              dendreo.participants(method: "post", datas: {id_participant: 1345, nom: "nouveau nom", civilite: "M.", id_add: 2})
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
              # Supprimer un participant (attention, il n'y a pas de methode "delete" sûr tous les endpoints)
         
     | 
| 
      
 99 
     | 
    
         
            +
              dendreo.participants(method: "delete", datas: {id_participant: 1345})
         
     | 
| 
       77 
100 
     | 
    
         | 
| 
       78 
101 
     | 
    
         
             
            ```
         
     | 
| 
       79 
102 
     | 
    
         
             
            Cet exemple fonctionne sur toutes les ressources sauf les "particuliers" que l'on peut créer mais pas modifier.
         
     | 
    
        data/dendreo.gemspec
    CHANGED
    
    
    
        data/lib/dendreo/version.rb
    CHANGED
    
    
    
        data/lib/dendreo.rb
    CHANGED
    
    | 
         @@ -1,5 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "dendreo/version"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "json"
         
     | 
| 
       2 
3 
     | 
    
         
             
            require 'net/http'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "rest-client"
         
     | 
| 
       3 
5 
     | 
    
         
             
            module Dendreo
         
     | 
| 
       4 
6 
     | 
    
         
             
              class API
         
     | 
| 
       5 
7 
     | 
    
         
             
                attr_accessor :url
         
     | 
| 
         @@ -14,36 +16,33 @@ module Dendreo 
     | 
|
| 
       14 
16 
     | 
    
         
             
                  method_name_string = method_name.to_s
         
     | 
| 
       15 
17 
     | 
    
         
             
                  request_method = args.first[:method]
         
     | 
| 
       16 
18 
     | 
    
         
             
                  datas = args.any? ? args.first[:datas] : {}
         
     | 
| 
      
 19 
     | 
    
         
            +
                  base_url = "#{@url}/#{method_name_string}.php?key=#{@api_key}"
         
     | 
| 
       17 
20 
     | 
    
         
             
                  case request_method
         
     | 
| 
       18 
21 
     | 
    
         
             
                  when "get"
         
     | 
| 
       19 
     | 
    
         
            -
                     
     | 
| 
       20 
     | 
    
         
            -
                    url = "#{@url}/#{method_name_string}.php?key=#{@api_key}#{args_formatted}"
         
     | 
| 
       21 
     | 
    
         
            -
                    puts url
         
     | 
| 
       22 
     | 
    
         
            -
                    get(url)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    send_it(:get, "#{base_url}#{format_args_to_url(datas)}")
         
     | 
| 
       23 
23 
     | 
    
         
             
                  when "post"
         
     | 
| 
       24 
     | 
    
         
            -
                    post 
     | 
| 
      
 24 
     | 
    
         
            +
                    send_it(:post, "#{base_url}", datas)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  when "delete"
         
     | 
| 
      
 26 
     | 
    
         
            +
                    send_it(:delete, "#{base_url}#{format_args_to_url(datas)}")
         
     | 
| 
      
 27 
     | 
    
         
            +
                  else
         
     | 
| 
      
 28 
     | 
    
         
            +
                    raise "Méthode inconnue '#{request_method}' !"
         
     | 
| 
       25 
29 
     | 
    
         
             
                  end
         
     | 
| 
       26 
30 
     | 
    
         
             
                end
         
     | 
| 
       27 
31 
     | 
    
         | 
| 
       28 
32 
     | 
    
         
             
                private
         
     | 
| 
       29 
33 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
                def  
     | 
| 
       31 
     | 
    
         
            -
                   
     | 
| 
       32 
     | 
    
         
            -
                   
     | 
| 
       33 
     | 
    
         
            -
                   
     | 
| 
       34 
     | 
    
         
            -
                  JSON.parse(res)
         
     | 
| 
       35 
     | 
    
         
            -
                end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                def get(url)
         
     | 
| 
       38 
     | 
    
         
            -
                  uri = URI(url)
         
     | 
| 
       39 
     | 
    
         
            -
                  result = Net::HTTP.get(uri)
         
     | 
| 
       40 
     | 
    
         
            -
                  res = result == "" ? "[{}]" : result
         
     | 
| 
       41 
     | 
    
         
            -
                  JSON.parse(res)
         
     | 
| 
      
 34 
     | 
    
         
            +
                def send_it(http_method, url, options = {})
         
     | 
| 
      
 35 
     | 
    
         
            +
                  hsh = {url: url, method: http_method }
         
     | 
| 
      
 36 
     | 
    
         
            +
                  hsh.merge!(payload: options) if http_method == :post
         
     | 
| 
      
 37 
     | 
    
         
            +
                  response_json(RestClient::Request.execute(hsh))
         
     | 
| 
       42 
38 
     | 
    
         
             
                end
         
     | 
| 
       43 
39 
     | 
    
         | 
| 
       44 
40 
     | 
    
         
             
                def format_args_to_url(args = {})
         
     | 
| 
       45 
41 
     | 
    
         
             
                  args.any? ? args.map{|k, v| k == args.keys.first ? "&#{k}=#{v}" : "#{k}=#{v}" }.join("&") : ""
         
     | 
| 
       46 
42 
     | 
    
         
             
                end
         
     | 
| 
       47 
43 
     | 
    
         | 
| 
      
 44 
     | 
    
         
            +
                def response_json(result)
         
     | 
| 
      
 45 
     | 
    
         
            +
                  JSON.parse(result == "" ? "[{}]" : result)
         
     | 
| 
      
 46 
     | 
    
         
            +
                end
         
     | 
| 
       48 
47 
     | 
    
         
             
              end
         
     | 
| 
       49 
48 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: Dendreo
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - ronan louarn
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-12-11 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -52,6 +52,20 @@ dependencies: 
     | 
|
| 
       52 
52 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       53 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
54 
     | 
    
         
             
                    version: '3.0'
         
     | 
| 
      
 55 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 56 
     | 
    
         
            +
              name: rest-client
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 62 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 63 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 64 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       55 
69 
     | 
    
         
             
            description: Simple gem for Dendreo CRM API
         
     | 
| 
       56 
70 
     | 
    
         
             
            email:
         
     | 
| 
       57 
71 
     | 
    
         
             
            - ronan33720@hotmail.Com
         
     | 
| 
         @@ -62,6 +76,8 @@ files: 
     | 
|
| 
       62 
76 
     | 
    
         
             
            - ".gitignore"
         
     | 
| 
       63 
77 
     | 
    
         
             
            - ".rspec"
         
     | 
| 
       64 
78 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
      
 79 
     | 
    
         
            +
            - Dendreo-1.0.0.gem
         
     | 
| 
      
 80 
     | 
    
         
            +
            - Dendreo-1.0.1.gem
         
     | 
| 
       65 
81 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       66 
82 
     | 
    
         
             
            - LICENSE.txt
         
     | 
| 
       67 
83 
     | 
    
         
             
            - README.md
         
     |