ecs_claims_ruby 0.1.0

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: 514ebd91eb5409815896c5d30b51e1cdae3ac31c
4
+ data.tar.gz: a419843e27e9701df50f875ed24a09351b15b34e
5
+ SHA512:
6
+ metadata.gz: a2e0352c22318709c610c385d019ee40965be34bc1337251b14d7bf745691ae23dd00daae3c96afc529736ca985ab4eb7495304aeb799bac5932b59bed5011fb
7
+ data.tar.gz: ae275feed21e59247b033f8eb696841d897bb57eea348c9a8f50dc82c188d02bda89f77643449b5c565527938373f48a3997180756d4ae60afa2642d5b7fd539
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ecs_claims_ruby.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Amed Rodriguez
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,73 @@
1
+ # ECS Claims Ruby Gem
2
+
3
+ A Ruby wrapper for the ECS Claims API.
4
+
5
+ You should access the ECS Claims API documentation in order to learn more about the
6
+ request/response parameters for each endpoint.
7
+
8
+ ## Installation
9
+
10
+ ```
11
+ $ gem install ecs_claims_ruby
12
+ ```
13
+
14
+ Or if you are using Bundler, add
15
+
16
+ ````
17
+ gem 'ecs_claims_ruby'
18
+ ```
19
+
20
+ ## API Usage Examples
21
+
22
+ You will need to get an access token. Once you have it, initialize the client
23
+ to make authenticated calls.
24
+
25
+ ```ruby
26
+ require 'ecs_claims_ruby'
27
+
28
+ client = EcsClaims::Client.new(token: '<redacted>', url: '<redacted>',
29
+ rfc: '<redacted>')
30
+ ```
31
+
32
+ ### Claims
33
+
34
+ Create a claim.
35
+
36
+ ```ruby
37
+ attributes = {
38
+ Paciente: {
39
+ fichaEmp: '98',
40
+ numEmpresa: '0',
41
+ curp: 'VICTALPPRCV376MNIV',
42
+ numCod: '5',
43
+ nombre: 'TALENS VICENTE ISIDRO'
44
+ },
45
+ Cuenta: {
46
+ numEvento: '1',
47
+ fechaAdm: '2016-01-06T13:37:56',
48
+ fechaAlta: '2016-01-06T13:41:01',
49
+ folioAut: 'EC0000000005',
50
+ total: 0,
51
+ estatus: 'C',
52
+ cedula: '684097',
53
+ medico: 'LUIS ANTONIO TORRES FACUNDO',
54
+ tipo: 'H'
55
+ },
56
+ listaDx: {}
57
+ }
58
+
59
+ claim = EcsClaims::Claim.new(client)
60
+ response = claim.create(attributes)
61
+ response.inspect
62
+ ```
63
+ Retrieve existing claim
64
+
65
+ ```ruby
66
+ response = claim.create(attributes)
67
+ response = claim.fetch(response['id'])
68
+ response.inspect
69
+ ```
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ecs_claims_ruby"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ecs_claims/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ecs_claims_ruby"
8
+ spec.version = EcsClaims::VERSION
9
+ spec.authors = ["Amed Rodriguez"]
10
+ spec.email = ["amed.rdz@gmail.com"]
11
+
12
+ spec.summary = %q{ECS Claims Ruby Wrapper}
13
+ spec.homepage = "https://github.com/ecaresoft/ecs_claims_ruby"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.10"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec"
32
+ spec.add_development_dependency "webmock"
33
+ spec.add_development_dependency "vcr"
34
+ spec.add_development_dependency "pry"
35
+
36
+ spec.add_dependency "faraday"
37
+ spec.add_dependency "faraday_middleware"
38
+ spec.add_dependency "json"
39
+ end
@@ -0,0 +1,24 @@
1
+ module EcsClaims
2
+ class Claim
3
+ def initialize(client)
4
+ @client = client
5
+ end
6
+
7
+ def create(parameters={})
8
+ client.request(:post, "/proveedores/#{rfc}/eventos", parameters)
9
+ end
10
+
11
+ def fetch(id)
12
+ client.request(:get, "/proveedores/#{rfc}/eventos/#{id}")
13
+ end
14
+
15
+ private
16
+ def rfc
17
+ client.rfc
18
+ end
19
+
20
+ def client
21
+ @client
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,64 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+
4
+ module EcsClaims
5
+ class Client
6
+ attr_reader :rfc
7
+
8
+ def initialize(options={})
9
+ @token = options[:token]
10
+ @url = options[:url]
11
+ @rfc = options[:rfc]
12
+ end
13
+
14
+ def request(type, path, params={})
15
+ block = Proc.new do |request|
16
+ request.url path
17
+ request.headers['Authorization'] = "Token #{token}"
18
+ request.headers['Content-Type'] = 'application/json'
19
+ end
20
+
21
+ send("#{type}_request", path, params, &block)
22
+ end
23
+
24
+ private
25
+ def put_request(path, params={}, &block)
26
+ connection.put do |request|
27
+ yield(request)
28
+ request.body = params.to_json
29
+ end
30
+ .body
31
+ end
32
+
33
+ def post_request(path, params={}, &block)
34
+ connection.post do |request|
35
+ yield(request)
36
+ request.body = params.to_json
37
+ end
38
+ .body
39
+ end
40
+
41
+ def get_request(path, params={}, &block)
42
+ connection.get do |request|
43
+ yield(request)
44
+ params.each { |key, val| request.params[key] = val }
45
+ end
46
+ .body
47
+ end
48
+
49
+ def token
50
+ @token
51
+ end
52
+
53
+ def url
54
+ @url
55
+ end
56
+
57
+ def connection
58
+ @connection ||= Faraday.new(url: url) do |b|
59
+ b.adapter Faraday.default_adapter
60
+ b.use FaradayMiddleware::ParseJson
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,3 @@
1
+ module EcsClaims
2
+ VERSION = "0.1.0"
3
+ end
data/lib/ecs_claims.rb ADDED
@@ -0,0 +1,6 @@
1
+ require_relative 'ecs_claims/version'
2
+ require_relative 'ecs_claims/client'
3
+ require_relative 'ecs_claims/claim'
4
+
5
+ module EcsClaims
6
+ end
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ecs_claims_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Amed Rodriguez
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-01-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.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.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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
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'
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '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'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: faraday_middleware
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: json
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description:
140
+ email:
141
+ - amed.rdz@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".travis.yml"
148
+ - CODE_OF_CONDUCT.md
149
+ - Gemfile
150
+ - LICENSE.txt
151
+ - README.md
152
+ - Rakefile
153
+ - bin/console
154
+ - bin/setup
155
+ - ecs_claims_ruby.gemspec
156
+ - lib/ecs_claims.rb
157
+ - lib/ecs_claims/claim.rb
158
+ - lib/ecs_claims/client.rb
159
+ - lib/ecs_claims/version.rb
160
+ homepage: https://github.com/ecaresoft/ecs_claims_ruby
161
+ licenses:
162
+ - MIT
163
+ metadata:
164
+ allowed_push_host: https://rubygems.org
165
+ post_install_message:
166
+ rdoc_options: []
167
+ require_paths:
168
+ - lib
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ requirements: []
180
+ rubyforge_project:
181
+ rubygems_version: 2.4.5
182
+ signing_key:
183
+ specification_version: 4
184
+ summary: ECS Claims Ruby Wrapper
185
+ test_files: []