Dendreo 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 63be47926eb0cd7bb5ab066e23190dfece71b99f
4
+ data.tar.gz: d07400d7f2e1feab51692777c552f50b0618423a
5
+ SHA512:
6
+ metadata.gz: f491551e788fbcb198ea18ecf74e0f168f8e129171bf217d08d6bb03340c94465435702246de752c1f9110ae2b4f4fd3a042ac4637598fbb017c6e5497e823ac
7
+ data.tar.gz: 0bbcec8f155706ffd246dc4724a9ba1ea168465b4d10dc2cb52134137fc2a1db4b17dab7ce7286e3678400de54175298034dfe9dc82b61b048d89400f90e19b2
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.3
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in dendreo.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 ronan louarn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # Dendreo
2
+
3
+ Gem pour l'API du CRM Dendreo.
4
+
5
+
6
+ ## Installation
7
+
8
+ Ajoutez cette à votre Gemfile:
9
+
10
+ ```ruby
11
+ gem 'dendreo'
12
+ ```
13
+
14
+ Bien entendu:
15
+
16
+ $ bundle
17
+
18
+ Ou installez le gem vous-même:
19
+
20
+ $ gem install dendreo
21
+
22
+ ## Démarrage rapide
23
+
24
+
25
+ Instanciez votre API.
26
+
27
+ ```ruby
28
+ dendreo = Dendreo::API.new("https://pro.dendreo.com/masociété/api", "MaCleApi")
29
+ ```
30
+ Attention à bien vérifier que votre url à bien ce format:
31
+
32
+ ```ruby
33
+ 'https://pro.dendreo.com/masociété/api'
34
+ ```
35
+
36
+ ## Utilisation:
37
+
38
+ Je vous invite à bien lire la documentation de l'api ici => https://developers.dendreo.com/
39
+
40
+ La gem utilise la "method_missing", il vous suffira donc de récupérer le nom de la resource que vous souhaitez récupérer, ajouter ou modifier (hé oui c'est possible!).
41
+
42
+ Exemple:
43
+
44
+ Il faut donc piocher le nom de la ressource tel quel est dans l'url de la requête API.
45
+
46
+ Pour les participants ( GET https://pro.dendreo.com/demo/api/participants.php?)
47
+
48
+ ```ruby
49
+ # Renvoi tous les particpants
50
+ dendreo.participants(method: "get")
51
+
52
+ # Renvoi le particpant qui a l'id en question
53
+ dendreo.participants(method: "get", datas: {id_participant: 1345})
54
+
55
+ # Renvoi le ou les particpants qui ont l'email en question
56
+ dendreo.participants(method: "get", datas: {email: "mon_email@gmail.com"})
57
+
58
+ #Renvoi le ou les particpants qui ont le commentaire en question
59
+ dendreo.participants(method: "get", datas: {search: "Un joli nom ou ce que vous souhaitez id, email, commentaires etc.."})
60
+ ```
61
+
62
+ Ajouter ou modifier un participant.
63
+
64
+ Attention, pour modifier un participant déjà existant, il vous suffit de remplacer "id_participant" par "id" tout court et d'ajouter un "id_add" qui contiendra un id d'administrateur.
65
+
66
+ 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
+
68
+ L'API est faite comme cela, je n'y peut rien. Ceci n'est pas encore spécifié dans la documentation.
69
+ Faites appel au support dendreo pour plus d'informations, ils sont très réactifs equipe@dendreo.com .
70
+
71
+ ```ruby
72
+ # Créer un participant
73
+ dendreo.participants(method: "post", datas: {nom: "nouveau nom", prenom: "toto", civilite: "M.", email: "toto@gmail.com", id_add: 2})
74
+
75
+ # Modifier un participant existant
76
+ dendreo.participants(method: "post", datas: {id: 1345, nom: "nouveau nom", civilite: "M.", id_add: 2})
77
+
78
+ ```
79
+ Cet exemple fonctionne sur toutes les ressources sauf les "particuliers" que l'on peut créer mais pas modifier.
80
+
81
+
82
+ ## Contribution
83
+
84
+ Rapports de bugs et contibutions ici => https://github.com/RonanLOUARN/dendreo.
85
+
86
+ ## Licence
87
+
88
+ Cette gem est opensource.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dendreo"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/dendreo.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "dendreo/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "Dendreo"
8
+ spec.version = Dendreo::VERSION
9
+ spec.authors = ["ronan louarn"]
10
+ spec.email = ["ronan33720@hotmail.Com"]
11
+
12
+ spec.summary = %q{Simple gem for Dendreo CRM API}
13
+ spec.description = %q{Simple gem for Dendreo CRM API}
14
+ spec.homepage = "http://lr-dev.fr"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.15"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ end
data/lib/dendreo.rb ADDED
@@ -0,0 +1,49 @@
1
+ require "dendreo/version"
2
+ require 'net/http'
3
+ module Dendreo
4
+ class API
5
+ attr_accessor :url
6
+ attr_accessor :api_key
7
+
8
+ def initialize(url, api_key)
9
+ @url = url #exemple = https://pro.dendreo.com/my_company/api
10
+ @api_key = api_key
11
+ end
12
+
13
+ def method_missing(method_name, *args)
14
+ method_name_string = method_name.to_s
15
+ request_method = args.first[:method]
16
+ datas = args.any? ? args.first[:datas] : {}
17
+ case request_method
18
+ when "get"
19
+ args_formatted = format_args_to_url(datas)
20
+ url = "#{@url}/#{method_name_string}.php?key=#{@api_key}#{args_formatted}"
21
+ puts url
22
+ get(url)
23
+ when "post"
24
+ post("#{@url}/#{method_name_string}.php?key=#{@api_key}", args.first[:datas])
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def post( url, options = {})
31
+ uri = URI(url)
32
+ result = Net::HTTP.post_form(uri, options)
33
+ res = result == "" ? "[{}]" : result.body
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)
42
+ end
43
+
44
+ def format_args_to_url(args = {})
45
+ args.any? ? args.map{|k, v| k == args.keys.first ? "&#{k}=#{v}" : "#{k}=#{v}" }.join("&") : ""
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module Dendreo
2
+ VERSION = "1.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Dendreo
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - ronan louarn
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-10-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Simple gem for Dendreo CRM API
56
+ email:
57
+ - ronan33720@hotmail.Com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - dendreo.gemspec
72
+ - lib/dendreo.rb
73
+ - lib/dendreo/version.rb
74
+ homepage: http://lr-dev.fr
75
+ licenses:
76
+ - MIT
77
+ metadata:
78
+ allowed_push_host: https://rubygems.org
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.6.11
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Simple gem for Dendreo CRM API
99
+ test_files: []