segurofacil-ruby 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +53 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +99 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/segurofacil.rb +31 -0
- data/lib/segurofacil/apolice.rb +53 -0
- data/lib/segurofacil/estagiario.rb +70 -0
- data/lib/segurofacil/estagiarios.rb +22 -0
- data/lib/segurofacil/responses/apolice_cancel_response.rb +7 -0
- data/lib/segurofacil/responses/apolice_create_response.rb +7 -0
- data/lib/segurofacil/responses/estagiario_create_response.rb +12 -0
- data/lib/segurofacil/responses/estagiario_remove_response.rb +7 -0
- data/lib/segurofacil/responses/estagiarios_get_response.rb +11 -0
- data/lib/segurofacil/responses/response.rb +24 -0
- data/lib/segurofacil/rest/apolice_cancel.rb +18 -0
- data/lib/segurofacil/rest/apolice_create.rb +18 -0
- data/lib/segurofacil/rest/estagiario_create.rb +19 -0
- data/lib/segurofacil/rest/estagiario_remove.rb +19 -0
- data/lib/segurofacil/rest/estagiarios_get.rb +16 -0
- data/lib/segurofacil/rest/request.rb +74 -0
- data/lib/segurofacil/version.rb +3 -0
- data/segurofacil.gemspec +29 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d508698ac0580a43d3d84fd390bfa862e7795dc6
|
4
|
+
data.tar.gz: 1ae899ea95f67f3200823528374530eb2655540a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 047751e04650dfb730c9a7ce815de91bcb74962fd6c64de556ca4702a5c98b5a83e8228396a433aaa5e4cb6a31ccf7fe03dd320c0cd25867b2dae064b7af68a7
|
7
|
+
data.tar.gz: 67d86a2e4c4f264e1c0368c76f2c4599c55557011522766488a4a8b6360168ebc088fe7f8beb072fae9cad23bf518997e55ca9cfe4bb4f7182d6585e664e1555
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.env
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
segurofacil-ruby (0.1.7)
|
5
|
+
multi_json
|
6
|
+
rest-client
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
diff-lcs (1.2.5)
|
12
|
+
domain_name (0.5.20160310)
|
13
|
+
unf (>= 0.0.5, < 1.0.0)
|
14
|
+
dotenv (2.1.1)
|
15
|
+
http-cookie (1.0.2)
|
16
|
+
domain_name (~> 0.5)
|
17
|
+
mime-types (2.99.1)
|
18
|
+
multi_json (1.12.1)
|
19
|
+
netrc (0.11.0)
|
20
|
+
rake (10.5.0)
|
21
|
+
rest-client (1.8.0)
|
22
|
+
http-cookie (>= 1.0.2, < 2.0)
|
23
|
+
mime-types (>= 1.16, < 3.0)
|
24
|
+
netrc (~> 0.7)
|
25
|
+
rspec (3.4.0)
|
26
|
+
rspec-core (~> 3.4.0)
|
27
|
+
rspec-expectations (~> 3.4.0)
|
28
|
+
rspec-mocks (~> 3.4.0)
|
29
|
+
rspec-core (3.4.4)
|
30
|
+
rspec-support (~> 3.4.0)
|
31
|
+
rspec-expectations (3.4.0)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.4.0)
|
34
|
+
rspec-mocks (3.4.1)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.4.0)
|
37
|
+
rspec-support (3.4.1)
|
38
|
+
unf (0.1.4)
|
39
|
+
unf_ext
|
40
|
+
unf_ext (0.0.7.2)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
bundler (~> 1.11)
|
47
|
+
dotenv
|
48
|
+
rake (~> 10.0)
|
49
|
+
rspec (~> 3.0)
|
50
|
+
segurofacil-ruby!
|
51
|
+
|
52
|
+
BUNDLED WITH
|
53
|
+
1.11.2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Guilherme Kenedy Ferreira
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Guilherme
|
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,99 @@
|
|
1
|
+
# Segurofacil
|
2
|
+
|
3
|
+
[SeguroFacil](https://www.segurofacil.com.br/) ruby API library
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'segurofacil-ruby'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install segurofacil-ruby
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Make sure you have the following variables in your environment.
|
23
|
+
|
24
|
+
```
|
25
|
+
SEGUROFACIL_PARTNER_NAME - Your segurofacil identifier
|
26
|
+
SEGUROFACIL_EMAIL - Authentication email
|
27
|
+
SEGUROFACIL_PASSWORD - Authentication password
|
28
|
+
```
|
29
|
+
|
30
|
+
### Insurance Policy
|
31
|
+
|
32
|
+
#### Creating a new insurance policy
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
Segurofacil::Apolice.create({
|
36
|
+
name: "Company Test",
|
37
|
+
razaoSocial: "Company Test",
|
38
|
+
cNPJ: "33.333.333/0001-33",
|
39
|
+
responsavel: "Test",
|
40
|
+
cPF: "333.333.333-33",
|
41
|
+
qualificacao: "Test",
|
42
|
+
email: "user@email.com",
|
43
|
+
telefone: "35555555",
|
44
|
+
atividade: "Test",
|
45
|
+
address1: "Test",
|
46
|
+
address2: "Test",
|
47
|
+
bairro: "Manhattan",
|
48
|
+
city: "NYC",
|
49
|
+
estado: "NY",
|
50
|
+
cep: "12345678"
|
51
|
+
})
|
52
|
+
```
|
53
|
+
|
54
|
+
#### Cancelling an insurance policy
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
Segurofacil::Apolice.cancel(cnpj)
|
58
|
+
```
|
59
|
+
|
60
|
+
### Intern
|
61
|
+
|
62
|
+
#### Adding intern
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
Segurofacil::Estagiario.create(
|
66
|
+
{
|
67
|
+
nome: 'name',
|
68
|
+
cpf: 'document_cpf',
|
69
|
+
dob: 'date_of_birth',
|
70
|
+
sexoId: sex_id # 1 for male and 2 for female
|
71
|
+
},
|
72
|
+
cnpj
|
73
|
+
)
|
74
|
+
```
|
75
|
+
|
76
|
+
#### Listing interns
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
Segurofacil::Estagiarios.get(cnpj)
|
80
|
+
```
|
81
|
+
|
82
|
+
#### Remove intern from insurance policy
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
Segurofacil::Estagiario.remove(intern_document_cpf, cnpj)
|
86
|
+
```
|
87
|
+
|
88
|
+
## License
|
89
|
+
|
90
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
91
|
+
|
92
|
+
## TODO
|
93
|
+
|
94
|
+
- [x] Create Apolice
|
95
|
+
- [x] Cancel Apolice
|
96
|
+
- [x] Add Estagiario
|
97
|
+
- [x] Remove Estagiario
|
98
|
+
- [x] Get Estagiarios
|
99
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "segurofacil/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
data/lib/segurofacil.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'segurofacil/rest/request'
|
2
|
+
require 'segurofacil/rest/apolice_cancel'
|
3
|
+
require 'segurofacil/rest/apolice_create'
|
4
|
+
require 'segurofacil/rest/estagiario_create'
|
5
|
+
require 'segurofacil/rest/estagiario_remove'
|
6
|
+
require 'segurofacil/rest/estagiarios_get'
|
7
|
+
|
8
|
+
require 'segurofacil/responses/response'
|
9
|
+
require 'segurofacil/responses/apolice_cancel_response'
|
10
|
+
require 'segurofacil/responses/apolice_create_response'
|
11
|
+
require 'segurofacil/responses/estagiario_create_response'
|
12
|
+
require 'segurofacil/responses/estagiario_remove_response'
|
13
|
+
require 'segurofacil/responses/estagiarios_get_response'
|
14
|
+
|
15
|
+
require 'segurofacil/version'
|
16
|
+
require 'segurofacil/apolice'
|
17
|
+
require 'segurofacil/estagiario'
|
18
|
+
require 'segurofacil/estagiarios'
|
19
|
+
|
20
|
+
module Segurofacil
|
21
|
+
|
22
|
+
class << self
|
23
|
+
attr_accessor :api_base, :partner_name, :email, :password
|
24
|
+
end
|
25
|
+
|
26
|
+
self.api_base = 'https://www.segurofacil.com.br/parceiros/api'.freeze
|
27
|
+
self.partner_name = ENV['SEGUROFACIL_PARTNER_NAME']
|
28
|
+
self.email = ENV['SEGUROFACIL_EMAIL']
|
29
|
+
self.password = ENV['SEGUROFACIL_PASSWORD']
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Segurofacil
|
2
|
+
class Apolice
|
3
|
+
|
4
|
+
extend Segurofacil::REST::ApoliceCreate
|
5
|
+
extend Segurofacil::REST::ApoliceCancel
|
6
|
+
|
7
|
+
class << self
|
8
|
+
|
9
|
+
# Create a new insurance policy
|
10
|
+
# @param company [Hash] the new insurance holder
|
11
|
+
# @return [ApoliceCreateResponse]
|
12
|
+
# @example Create new policy
|
13
|
+
# Segurofacil::Apolice.create({
|
14
|
+
# name: "Company Test",
|
15
|
+
# razaoSocial: "Company Test",
|
16
|
+
# cNPJ: "33.333.333/0001-33",
|
17
|
+
# responsavel: "Test",
|
18
|
+
# cPF: "333.333.333-33",
|
19
|
+
# qualificacao: "Test",
|
20
|
+
# email: "user@email.com",
|
21
|
+
# telefone: "35555555",
|
22
|
+
# atividade: "Test",
|
23
|
+
# address1: "Test",
|
24
|
+
# address2: "Test",
|
25
|
+
# bairro: "Manhattan",
|
26
|
+
# city: "NYC",
|
27
|
+
# estado: "NY",
|
28
|
+
# cep: "12345678"
|
29
|
+
# })
|
30
|
+
def create(company)
|
31
|
+
res = super company
|
32
|
+
get_create_response(res)
|
33
|
+
end
|
34
|
+
|
35
|
+
def cancel(cnpj)
|
36
|
+
res = super cnpj
|
37
|
+
get_cancel_response(res)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def get_create_response(res)
|
43
|
+
Segurofacil::Responses::ApoliceCreateResponse.new(res)
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_cancel_response(res)
|
47
|
+
Segurofacil::Responses::ApoliceCancelResponse.new(res)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Segurofacil
|
2
|
+
class Estagiario
|
3
|
+
|
4
|
+
extend Segurofacil::REST::EstagiarioCreate
|
5
|
+
extend Segurofacil::REST::EstagiarioRemove
|
6
|
+
|
7
|
+
NAME='nome'
|
8
|
+
CPF='cPF'
|
9
|
+
BIRTHDATE='dOB'
|
10
|
+
GENDER='sexoId'
|
11
|
+
|
12
|
+
MALE=1
|
13
|
+
FEMALE=2
|
14
|
+
|
15
|
+
attr_reader :name, :cpf, :birthdate, :gender
|
16
|
+
|
17
|
+
def initialize(options)
|
18
|
+
@name = options.fetch(NAME)
|
19
|
+
@cpf = options.fetch(CPF)
|
20
|
+
@birthdate = options.fetch(BIRTHDATE)
|
21
|
+
@gender = options.fetch(GENDER)
|
22
|
+
end
|
23
|
+
|
24
|
+
def male?
|
25
|
+
gender == MALE
|
26
|
+
end
|
27
|
+
|
28
|
+
def female?
|
29
|
+
gender == FEMALE
|
30
|
+
end
|
31
|
+
|
32
|
+
class << self
|
33
|
+
|
34
|
+
def create(estagiario, cnpj)
|
35
|
+
res = super estagiario, cnpj
|
36
|
+
get_create_response(res)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Remove a estagiario from the policy
|
40
|
+
# @param estagiario_cpf [String] the estagiario to be removed
|
41
|
+
# @param cnpj [String] the cnpj of the company that holds the estagiario's policy
|
42
|
+
# @return EstagiarioRemoveResponse
|
43
|
+
def remove(estagiario_cpf, cnpj)
|
44
|
+
res = super estagiario_cpf, cnpj
|
45
|
+
get_remove_response(res)
|
46
|
+
end
|
47
|
+
|
48
|
+
def convert_to_estagiario(hash)
|
49
|
+
self.new hash
|
50
|
+
end
|
51
|
+
|
52
|
+
def ary_to_estagiarios(list)
|
53
|
+
return [] if list.nil?
|
54
|
+
list.map {|item| convert_to_estagiario(item) }
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def get_create_response(res)
|
60
|
+
Segurofacil::Responses::EstagiarioCreateResponse.new(res)
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_remove_response(res)
|
64
|
+
Segurofacil::Responses::EstagiarioRemoveResponse.new(res)
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Segurofacil
|
2
|
+
class Estagiarios
|
3
|
+
|
4
|
+
extend Segurofacil::REST::EstagiariosGet
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def get(cnpj)
|
9
|
+
res = super({ cnpj: cnpj })
|
10
|
+
get_response(res)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def get_response(res)
|
16
|
+
Segurofacil::Responses::EstagiariosGetResponse.new(res)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Segurofacil
|
2
|
+
module Responses
|
3
|
+
class Response
|
4
|
+
|
5
|
+
HTTP_SUCCESS=[200, 201, 202, 203, 204, 205, 206, 207, 226]
|
6
|
+
|
7
|
+
attr_reader :status_code, :raw_body
|
8
|
+
|
9
|
+
def initialize(response)
|
10
|
+
@status_code = response.fetch(:code)
|
11
|
+
@raw_body = response.fetch(:body)
|
12
|
+
end
|
13
|
+
|
14
|
+
def success?
|
15
|
+
HTTP_SUCCESS.include? status_code
|
16
|
+
end
|
17
|
+
|
18
|
+
def error?
|
19
|
+
!success?
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Segurofacil
|
2
|
+
module REST
|
3
|
+
module EstagiarioCreate
|
4
|
+
|
5
|
+
PATH = 'addestagiario'
|
6
|
+
|
7
|
+
def create(estagiario, cnpj)
|
8
|
+
Segurofacil::REST::Request.post(
|
9
|
+
PATH,
|
10
|
+
params: {
|
11
|
+
estagiario: estagiario,
|
12
|
+
cnpj: cnpj
|
13
|
+
}
|
14
|
+
).perform
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Segurofacil
|
2
|
+
module REST
|
3
|
+
module EstagiarioRemove
|
4
|
+
|
5
|
+
PATH = 'removeestagiario'
|
6
|
+
|
7
|
+
def remove(estagiario_cpf, cnpj)
|
8
|
+
Segurofacil::REST::Request.post(
|
9
|
+
PATH,
|
10
|
+
params: {
|
11
|
+
cpf: estagiario_cpf,
|
12
|
+
cnpj: cnpj
|
13
|
+
}
|
14
|
+
).perform
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module Segurofacil
|
5
|
+
module REST
|
6
|
+
class Request
|
7
|
+
|
8
|
+
attr_reader :path, :method, :parameters
|
9
|
+
|
10
|
+
DEFAULT_HEADERS = {
|
11
|
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
12
|
+
'Accept' => 'application/json',
|
13
|
+
'User-Agent' => "segurofacil-ruby/#{Segurofacil::VERSION}"
|
14
|
+
}
|
15
|
+
|
16
|
+
def initialize(path, method, options={})
|
17
|
+
@path = path
|
18
|
+
@method = method
|
19
|
+
@parameters = options.fetch(:params, Hash.new)
|
20
|
+
end
|
21
|
+
|
22
|
+
def perform
|
23
|
+
json_res = {}
|
24
|
+
|
25
|
+
begin
|
26
|
+
res = RestClient::Request.execute request_params
|
27
|
+
json_res[:body] = MultiJson.load res.body
|
28
|
+
json_res[:code] = res.code
|
29
|
+
rescue RestClient::ExceptionWithResponse => e
|
30
|
+
parsed_error = MultiJson.load e.http_body
|
31
|
+
|
32
|
+
json_res[:error] = true
|
33
|
+
json_res[:body] = parsed_error
|
34
|
+
json_res[:code] = e.response.code
|
35
|
+
end
|
36
|
+
|
37
|
+
json_res
|
38
|
+
end
|
39
|
+
|
40
|
+
class << self
|
41
|
+
|
42
|
+
def post(path, options={})
|
43
|
+
self.new path, 'POST', options
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def request_params
|
51
|
+
{
|
52
|
+
method: method,
|
53
|
+
url: resource_url,
|
54
|
+
payload: parameters.merge(credentials),
|
55
|
+
headers: DEFAULT_HEADERS
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def resource_url
|
60
|
+
"#{Segurofacil.api_base}/#{Segurofacil.partner_name}/#{path}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def credentials
|
64
|
+
{
|
65
|
+
credentials: {
|
66
|
+
email: Segurofacil.email,
|
67
|
+
password: Segurofacil.password
|
68
|
+
}
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/segurofacil.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'segurofacil/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "segurofacil-ruby"
|
8
|
+
spec.version = Segurofacil::VERSION
|
9
|
+
spec.authors = ["Guilherme"]
|
10
|
+
spec.email = ["guilhermekfe@outlook.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Gem to wrap segurofacil.com.br API}
|
13
|
+
spec.description = %q{Gem to wrap segurofacil.com.br API}
|
14
|
+
spec.homepage = "https://github.com/guilhermekfe/segurofacil-ruby"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
spec.add_development_dependency "dotenv"
|
26
|
+
|
27
|
+
spec.add_dependency 'rest-client'
|
28
|
+
spec.add_dependency 'multi_json'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: segurofacil-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guilherme
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-04 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dotenv
|
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: rest-client
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
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: multi_json
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Gem to wrap segurofacil.com.br API
|
98
|
+
email:
|
99
|
+
- guilhermekfe@outlook.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- Gemfile.lock
|
107
|
+
- LICENSE
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- lib/segurofacil.rb
|
114
|
+
- lib/segurofacil/apolice.rb
|
115
|
+
- lib/segurofacil/estagiario.rb
|
116
|
+
- lib/segurofacil/estagiarios.rb
|
117
|
+
- lib/segurofacil/responses/apolice_cancel_response.rb
|
118
|
+
- lib/segurofacil/responses/apolice_create_response.rb
|
119
|
+
- lib/segurofacil/responses/estagiario_create_response.rb
|
120
|
+
- lib/segurofacil/responses/estagiario_remove_response.rb
|
121
|
+
- lib/segurofacil/responses/estagiarios_get_response.rb
|
122
|
+
- lib/segurofacil/responses/response.rb
|
123
|
+
- lib/segurofacil/rest/apolice_cancel.rb
|
124
|
+
- lib/segurofacil/rest/apolice_create.rb
|
125
|
+
- lib/segurofacil/rest/estagiario_create.rb
|
126
|
+
- lib/segurofacil/rest/estagiario_remove.rb
|
127
|
+
- lib/segurofacil/rest/estagiarios_get.rb
|
128
|
+
- lib/segurofacil/rest/request.rb
|
129
|
+
- lib/segurofacil/version.rb
|
130
|
+
- segurofacil.gemspec
|
131
|
+
homepage: https://github.com/guilhermekfe/segurofacil-ruby
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.5.1
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: Gem to wrap segurofacil.com.br API
|
155
|
+
test_files: []
|