medlink 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0732ff602d91d1d476ba61be61f5093d4280ac84
4
+ data.tar.gz: c93b85df1f4ae6a9527e655212c8f8ce9be35a27
5
+ SHA512:
6
+ metadata.gz: a3a48be71014e57ab7acd38fe2ce714eb8140b4e71d9864411feb7632f62fb86266c4abe82f5361f6abe9c57b9171cab8bc93ed1b81a02a71ea6807d78bb1608
7
+ data.tar.gz: ee81d0aabb7fce94de129ed8a60ff4d2ff3124699366f8e1647f0ab4af0bf3d07098f2b74bbe424094601e27a96b583634b0d9bfdf3190347884501e22ea514c
@@ -0,0 +1,17 @@
1
+ .DS_Store
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -0,0 +1 @@
1
+ 2.2.3
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,68 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ medlink (0.1.0)
5
+ faraday (~> 0.9)
6
+ virtus (~> 1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.3.8)
12
+ axiom-types (0.1.1)
13
+ descendants_tracker (~> 0.0.4)
14
+ ice_nine (~> 0.11.0)
15
+ thread_safe (~> 0.3, >= 0.3.1)
16
+ coercible (1.0.0)
17
+ descendants_tracker (~> 0.0.1)
18
+ crack (0.4.2)
19
+ safe_yaml (~> 1.0.0)
20
+ descendants_tracker (0.0.4)
21
+ thread_safe (~> 0.3, >= 0.3.1)
22
+ diff-lcs (1.2.5)
23
+ equalizer (0.0.11)
24
+ faraday (0.9.2)
25
+ multipart-post (>= 1.2, < 3)
26
+ hashdiff (0.2.2)
27
+ ice_nine (0.11.1)
28
+ multipart-post (2.0.0)
29
+ rake (10.4.2)
30
+ rspec (3.3.0)
31
+ rspec-core (~> 3.3.0)
32
+ rspec-expectations (~> 3.3.0)
33
+ rspec-mocks (~> 3.3.0)
34
+ rspec-core (3.3.2)
35
+ rspec-support (~> 3.3.0)
36
+ rspec-expectations (3.3.1)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.3.0)
39
+ rspec-mocks (3.3.2)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.3.0)
42
+ rspec-support (3.3.0)
43
+ safe_yaml (1.0.4)
44
+ thread_safe (0.3.5)
45
+ vcr (2.9.3)
46
+ virtus (1.0.5)
47
+ axiom-types (~> 0.1)
48
+ coercible (~> 1.0)
49
+ descendants_tracker (~> 0.0, >= 0.0.3)
50
+ equalizer (~> 0.0, >= 0.0.9)
51
+ webmock (1.22.1)
52
+ addressable (>= 2.3.6)
53
+ crack (>= 0.3.2)
54
+ hashdiff
55
+
56
+ PLATFORMS
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ bundler (~> 1.10)
61
+ medlink!
62
+ rake (~> 10.4)
63
+ rspec (~> 3.3)
64
+ vcr (~> 2.9)
65
+ webmock (~> 1.22)
66
+
67
+ BUNDLED WITH
68
+ 1.10.6
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Etienne Depaulis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ # If you want to make this the default task
8
+ task default: :spec
@@ -0,0 +1,14 @@
1
+ module Medlink
2
+
3
+ require 'virtus'
4
+ require 'faraday'
5
+
6
+ require "medlink/version"
7
+ require 'medlink/client'
8
+ require 'medlink/api'
9
+ require 'medlink/configuration'
10
+ require 'medlink/speciality'
11
+ require 'medlink/city'
12
+ require 'medlink/interne'
13
+
14
+ end
@@ -0,0 +1,15 @@
1
+ module Medlink
2
+ class API
3
+
4
+ attr_reader :client
5
+
6
+ def initialize(current_token)
7
+ @client = Client.new(current_token)
8
+ end
9
+
10
+ def internes(params)
11
+ Interne.where(client, params)
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ module Medlink
2
+ class City
3
+ include Virtus.model
4
+
5
+ attribute :id, Integer
6
+ attribute :name, String
7
+
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ module Medlink
2
+ class Client
3
+
4
+ def initialize(api_key)
5
+ @api_key = api_key
6
+ end
7
+
8
+ attr_reader :api_key
9
+
10
+ def get(url, params = {})
11
+ params[:api_key] = api_key
12
+ client.get(api_url(url), params)
13
+ end
14
+
15
+ private
16
+
17
+ def client
18
+ @client ||= Faraday.new(url: site) do |faraday|
19
+ faraday.request :url_encoded # form-encode POST params
20
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
21
+ end
22
+ end
23
+
24
+ def site
25
+ Medlink.configuration.site
26
+ end
27
+
28
+ def api_url(url)
29
+ "/api/#{url}"
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,17 @@
1
+ module Medlink
2
+ class Configuration
3
+ attr_accessor :site
4
+
5
+ def initialize
6
+ @site = "http://medlink.planning-de-garde.fr/"
7
+ end
8
+ end
9
+
10
+ def self.configuration
11
+ @configuration ||= Configuration.new
12
+ end
13
+
14
+ def self.configure
15
+ yield(configuration) if block_given?
16
+ end
17
+ end
@@ -0,0 +1,34 @@
1
+ module Medlink
2
+ class Interne
3
+ include Virtus.model
4
+
5
+ attribute :id, Integer
6
+ attribute :first_name, String
7
+ attribute :last_name, String
8
+ attribute :ecn_year, Integer
9
+ attribute :ecn_ranking, Integer
10
+ attribute :internat_end_year, Integer
11
+ attribute :birthdate, Date
12
+ attribute :speciality, Medlink::Speciality
13
+ attribute :city, Medlink::City
14
+
15
+ def self.where(client, params)
16
+
17
+ response = client.get('/internes', params)
18
+
19
+ if response.status == 200
20
+ json = JSON.parse response.body
21
+
22
+ internes = []
23
+
24
+ json.each do |json_item|
25
+ internes << self.new(json_item)
26
+ end
27
+
28
+ internes
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,10 @@
1
+ module Medlink
2
+ class Speciality
3
+ include Virtus.model
4
+
5
+ attribute :id, Integer
6
+ attribute :name, String
7
+ attribute :duration, Integer
8
+
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module Medlink
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'medlink/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "medlink"
7
+ spec.version = Medlink::VERSION
8
+ spec.authors = ["Etienne Depaulis"]
9
+ spec.email = ["etienne@planning-de-garde.fr"]
10
+ spec.homepage = "https://bitbucket.org/EtienneDepaulis/medlink"
11
+ spec.description = %q{Medlink API ruby client}
12
+ spec.summary = %q{Medlink JSON API ruby client}
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", '~> 1.10'
21
+ spec.add_development_dependency "rake", '~> 10.4'
22
+ spec.add_development_dependency "rspec", '~> 3.3'
23
+ spec.add_development_dependency "vcr", '~> 2.9'
24
+ spec.add_development_dependency "webmock", '~> 1.22'
25
+
26
+ spec.add_runtime_dependency "virtus", '~> 1.0'
27
+ spec.add_runtime_dependency "faraday", '~> 0.9'
28
+ end
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://medlink.planning-de-garde.fr/api/internes?api_key=HKJbahe6Gehbrg2&first_name=Julien&last_name=Vibert
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.2
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - Cowboy
23
+ Date:
24
+ - Thu, 15 Oct 2015 17:19:05 GMT
25
+ Connection:
26
+ - keep-alive
27
+ X-Frame-Options:
28
+ - SAMEORIGIN
29
+ X-Xss-Protection:
30
+ - 1; mode=block
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ Etag:
36
+ - W/"5b91bef2b7984318149604459b9e185a"
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - 82f08034-0364-46a7-b381-76d5ee05d916
41
+ X-Runtime:
42
+ - '0.034235'
43
+ Vary:
44
+ - Accept-Encoding
45
+ Transfer-Encoding:
46
+ - chunked
47
+ Via:
48
+ - 1.1 vegur
49
+ body:
50
+ encoding: UTF-8
51
+ string: '[{"id":1,"first_name":"Julien","last_name":"Vibert","birthdate":"1990-07-16","ecn_year":2015,"ecn_ranking":1,"internat_end_year":2019,"city":{"id":1,"name":"Ile-de-France"},"speciality":{"id":1,"name":"oncologie","duration":5}}]'
52
+ http_version:
53
+ recorded_at: Thu, 15 Oct 2015 17:19:06 GMT
54
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Medlink::Interne do
4
+
5
+ describe ":internes" do
6
+
7
+ context "valid token" do
8
+ before(:each) do
9
+ VCR.use_cassette "internes" do
10
+ @internes = @api.internes(first_name: "Julien", last_name: "Vibert")
11
+ end
12
+ end
13
+
14
+ subject(:internes) { @internes }
15
+
16
+ let(:interne) { @internes.first }
17
+
18
+ it { expect(interne.ecn_ranking).to eq(1) }
19
+ it { expect(interne.ecn_year).to eq(2015) }
20
+ it { expect(interne.internat_end_year).to eq(2019) }
21
+ it { expect(interne.first_name).to eq("Julien") }
22
+ it { expect(interne.last_name).to eq("Vibert") }
23
+ it { expect(interne.birthdate).to eq Date.new(1990, 7, 16) }
24
+ it { expect(interne.speciality.name).to eq("oncologie") }
25
+ it { expect(interne.city.name).to eq("Ile-de-France") }
26
+
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,22 @@
1
+ require 'bundler/setup'
2
+ require 'webmock/rspec'
3
+ require 'vcr'
4
+
5
+ require_relative '../lib/medlink.rb'
6
+
7
+ VCR.configure do |c|
8
+ c.cassette_library_dir = 'spec/cassettes'
9
+ c.hook_into :webmock
10
+ c.allow_http_connections_when_no_cassette = false
11
+ c.before_record do |i|
12
+ i.response.body.force_encoding('UTF-8')
13
+ end
14
+ end
15
+
16
+ TOKEN = "HKJbahe6Gehbrg2"
17
+
18
+ RSpec.configure do |c|
19
+ c.before(:each) do
20
+ @api = Medlink::API.new(TOKEN)
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: medlink
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Etienne Depaulis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-20 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.4'
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.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.9'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.9'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.22'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.22'
83
+ - !ruby/object:Gem::Dependency
84
+ name: virtus
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: faraday
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.9'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.9'
111
+ description: Medlink API ruby client
112
+ email:
113
+ - etienne@planning-de-garde.fr
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".DS_Store"
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".ruby-version"
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - License.txt
125
+ - Rakefile
126
+ - lib/medlink.rb
127
+ - lib/medlink/api.rb
128
+ - lib/medlink/city.rb
129
+ - lib/medlink/client.rb
130
+ - lib/medlink/configuration.rb
131
+ - lib/medlink/interne.rb
132
+ - lib/medlink/speciality.rb
133
+ - lib/medlink/version.rb
134
+ - medlink.gemspec
135
+ - spec/cassettes/internes.yml
136
+ - spec/internes_spec.rb
137
+ - spec/spec_helper.rb
138
+ homepage: https://bitbucket.org/EtienneDepaulis/medlink
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.4.5.1
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: Medlink JSON API ruby client
162
+ test_files:
163
+ - spec/cassettes/internes.yml
164
+ - spec/internes_spec.rb
165
+ - spec/spec_helper.rb