mifiel 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1772670719d1f6b0a3701a741a365e1365aed0e5
4
- data.tar.gz: 6c35a0f222ce5fe6d21d7559fb813a6f41f2a1c9
3
+ metadata.gz: 4aabf349411f210a7f230fdf91f8936be65b570a
4
+ data.tar.gz: dfd5a2c74464483ab12a7ad4fac6df6af41aaefd
5
5
  SHA512:
6
- metadata.gz: dd0ca66ba48690fcfb88f5186293b0e8b4dcf1a96f2d903c5aa0f173ceecc6ba5cb5abbee468b567d21501707be7e23b73d7f3460506b509562cf05c8219a8b7
7
- data.tar.gz: 22f6a6bb79aa959591450e0e7267e078e20d543e460b61b58995ca808b4720004c9ddcf6a4dd3f5efbe13699616bb25c07866214231d64871547a2f7139f90a4
6
+ metadata.gz: 6db21aa9fa5c4b1bda2fbcf6592fae28bf8a418b80fda8ab5ebe2766ce50bf203e6028b46f61933252315aa6caf1c933e30c8e03549d3bea4139b272bd479849
7
+ data.tar.gz: 686568140c2bbc6c53eb7fdbf3826ad9d7deab2252a9440970aea64edab11a6756946fa81dc47314d568795b4bc2a5668de5034bc604ad252cd1b1347b6ee86b
data/README.md CHANGED
@@ -149,6 +149,22 @@ Certificate methods:
149
149
  certificate.delete
150
150
  ```
151
151
 
152
+ User methods
153
+
154
+ - Setup Widget
155
+
156
+ ```ruby
157
+ args = {
158
+ email: 'some@email.com',
159
+ tax_id: 'AAA010101AAA',
160
+ callback_url: 'http://some-callback.url'
161
+ }
162
+
163
+ user = Mifiel::User.setup_widget(args)
164
+ user.widget_id
165
+ ```
166
+
167
+
152
168
  ## Contributing
153
169
 
154
170
  1. Fork it ( https://github.com/[my-github-username]/mifiel/fork )
@@ -7,6 +7,7 @@ module Mifiel
7
7
  autoload :Certificate, 'mifiel/certificate'
8
8
  autoload :Template, 'mifiel/template'
9
9
  autoload :Config, 'mifiel/config'
10
+ autoload :User, 'mifiel/user'
10
11
 
11
12
  BASE_URL = 'https://www.mifiel.com/api/v1'.freeze
12
13
 
@@ -5,14 +5,15 @@ module Mifiel
5
5
  put :save, '/templates/:id'
6
6
  post :create, '/templates'
7
7
  delete :delete, '/templates/:id'
8
+ get :fields, '/templates/:id/fields'
8
9
 
9
10
  def generate_document(args = {})
10
11
  Mifiel::Document.create_from_template(args.merge(template_id: id))
11
12
  end
12
13
 
13
- def generate_documents(callback_url:, identifier: nil, documents:)
14
+ def generate_documents(callback_url:, documents:, identifier: nil)
14
15
  Mifiel::Document.create_many_from_template(
15
- template_id: template_id,
16
+ template_id: id,
16
17
  identifier: identifier,
17
18
  documents: documents,
18
19
  callback_url: callback_url
@@ -0,0 +1,27 @@
1
+ module Mifiel
2
+ class User < Mifiel::Base
3
+ post :setup_widget, '/users/setup-widget'
4
+
5
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
6
+ def self.setup_widget(args)
7
+ email = args[:email]
8
+ tax_id = args[:tax_id]
9
+ callback_url = args[:callback_url]
10
+
11
+ raise ArgumentError, 'Email must be provided' unless email
12
+ raise ArgumentError, 'Tax id must be provided' unless tax_id
13
+ rest_request = RestClient::Request.new(
14
+ url: "#{Mifiel.config.base_url}/users/setup-widget",
15
+ method: :post,
16
+ payload: {
17
+ email: email,
18
+ tax_id: tax_id,
19
+ callback_url: callback_url
20
+ },
21
+ ssl_version: 'SSLv23'
22
+ )
23
+ req = ApiAuth.sign!(rest_request, Mifiel.config.app_id, Mifiel.config.app_secret)
24
+ Mifiel::User.new(JSON.parse(req.execute))
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Mifiel
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.2.1'.freeze
3
3
  end
@@ -1,9 +1,9 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
4
  require 'mifiel/version'
5
5
 
6
- # rubocop:disable Metrics/BlockLength
6
+ # rubocop:disable Metrics/BlockLength, Layout/ExtraSpacing
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'mifiel'
9
9
  spec.version = Mifiel::VERSION
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
  spec.required_ruby_version = '~> 2.1'
21
21
 
22
- spec.add_runtime_dependency 'rest-client', '>= 1.8'
23
- spec.add_runtime_dependency 'json', '~> 1.8'
24
22
  spec.add_runtime_dependency 'api-auth', '~> 1.4'
23
+ spec.add_runtime_dependency 'json', '~> 1.8'
24
+ spec.add_runtime_dependency 'rest-client', '>= 1.8'
25
25
  # Use Gem::Version to parse the Ruby version for reliable comparison
26
26
  # ActiveSupport 5+ requires Ruby 2.2.2
27
27
  if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.2.2')
@@ -31,14 +31,14 @@ Gem::Specification.new do |spec|
31
31
  end
32
32
  spec.add_runtime_dependency 'flexirest', '~> 1.3.35'
33
33
 
34
+ spec.add_development_dependency 'bump', '~> 0.5', '>= 0.5.3'
34
35
  spec.add_development_dependency 'bundler', '~> 1.6'
35
- spec.add_development_dependency 'rake', '~> 10.0'
36
- spec.add_development_dependency 'rspec', '~> 3.1', '>= 3.1.7'
37
36
  spec.add_development_dependency 'byebug', '~> 9.0', '< 9.0.6'
38
37
  spec.add_development_dependency 'pry-byebug', '~> 3.4', '>= 3.3.0'
39
- spec.add_development_dependency 'bump', '~> 0.5', '>= 0.5.3'
40
- spec.add_development_dependency 'webmock', '~> 1.22', '>= 1.22.2'
41
- spec.add_development_dependency 'sinatra', '~> 1.4', '>= 1.4.7'
38
+ spec.add_development_dependency 'rake', '~> 10.0'
39
+ spec.add_development_dependency 'rspec', '~> 3.1', '>= 3.1.7'
42
40
  spec.add_development_dependency 'rubocop', '0.47.1'
43
41
  spec.add_development_dependency 'simplecov', '~> 0.15'
42
+ spec.add_development_dependency 'sinatra', '~> 1.4', '>= 1.4.7'
43
+ spec.add_development_dependency 'webmock', '~> 1.22', '>= 1.22.2'
44
44
  end
@@ -0,0 +1,14 @@
1
+ describe Mifiel::User do
2
+ describe '#setup_widget' do
3
+ let(:user) do
4
+ Mifiel::User.setup_widget(
5
+ email: 'user@email.com',
6
+ tax_id: 'AAA010101AAA',
7
+ callback_url: 'http://some-callback.url/mifiel'
8
+ )
9
+ end
10
+
11
+ it { expect(user.success).to be_truthy }
12
+ it { expect(user.widget_id).to_not be_nil }
13
+ end
14
+ end
@@ -99,6 +99,12 @@ class FakeMifiel < Sinatra::Base
99
99
  { bla: 'Correo enviado' }.to_json
100
100
  end
101
101
 
102
+ post '/api/v1/users/setup-widget' do
103
+ content_type :json
104
+ status 200
105
+ { widget_id: '123bc', success: true }.to_json
106
+ end
107
+
102
108
  private
103
109
 
104
110
  def template(args = {})
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mifiel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genaro Madrid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-15 00:00:00.000000000 Z
11
+ date: 2018-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rest-client
14
+ name: api-auth
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '1.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.8'
26
+ version: '1.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.8'
41
41
  - !ruby/object:Gem::Dependency
42
- name: api-auth
42
+ name: rest-client
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.4'
47
+ version: '1.8'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.4'
54
+ version: '1.8'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -81,53 +81,39 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.3.35
83
83
  - !ruby/object:Gem::Dependency
84
- name: bundler
84
+ name: bump
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.6'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.6'
97
- - !ruby/object:Gem::Dependency
98
- name: rake
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
89
+ version: '0.5'
90
+ - - ">="
102
91
  - !ruby/object:Gem::Version
103
- version: '10.0'
92
+ version: 0.5.3
104
93
  type: :development
105
94
  prerelease: false
106
95
  version_requirements: !ruby/object:Gem::Requirement
107
96
  requirements:
108
97
  - - "~>"
109
98
  - !ruby/object:Gem::Version
110
- version: '10.0'
99
+ version: '0.5'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 0.5.3
111
103
  - !ruby/object:Gem::Dependency
112
- name: rspec
104
+ name: bundler
113
105
  requirement: !ruby/object:Gem::Requirement
114
106
  requirements:
115
107
  - - "~>"
116
108
  - !ruby/object:Gem::Version
117
- version: '3.1'
118
- - - ">="
119
- - !ruby/object:Gem::Version
120
- version: 3.1.7
109
+ version: '1.6'
121
110
  type: :development
122
111
  prerelease: false
123
112
  version_requirements: !ruby/object:Gem::Requirement
124
113
  requirements:
125
114
  - - "~>"
126
115
  - !ruby/object:Gem::Version
127
- version: '3.1'
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: 3.1.7
116
+ version: '1.6'
131
117
  - !ruby/object:Gem::Dependency
132
118
  name: byebug
133
119
  requirement: !ruby/object:Gem::Requirement
@@ -169,93 +155,107 @@ dependencies:
169
155
  - !ruby/object:Gem::Version
170
156
  version: 3.3.0
171
157
  - !ruby/object:Gem::Dependency
172
- name: bump
158
+ name: rake
173
159
  requirement: !ruby/object:Gem::Requirement
174
160
  requirements:
175
161
  - - "~>"
176
162
  - !ruby/object:Gem::Version
177
- version: '0.5'
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: 0.5.3
163
+ version: '10.0'
181
164
  type: :development
182
165
  prerelease: false
183
166
  version_requirements: !ruby/object:Gem::Requirement
184
167
  requirements:
185
168
  - - "~>"
186
169
  - !ruby/object:Gem::Version
187
- version: '0.5'
188
- - - ">="
189
- - !ruby/object:Gem::Version
190
- version: 0.5.3
170
+ version: '10.0'
191
171
  - !ruby/object:Gem::Dependency
192
- name: webmock
172
+ name: rspec
193
173
  requirement: !ruby/object:Gem::Requirement
194
174
  requirements:
195
175
  - - "~>"
196
176
  - !ruby/object:Gem::Version
197
- version: '1.22'
177
+ version: '3.1'
198
178
  - - ">="
199
179
  - !ruby/object:Gem::Version
200
- version: 1.22.2
180
+ version: 3.1.7
201
181
  type: :development
202
182
  prerelease: false
203
183
  version_requirements: !ruby/object:Gem::Requirement
204
184
  requirements:
205
185
  - - "~>"
206
186
  - !ruby/object:Gem::Version
207
- version: '1.22'
187
+ version: '3.1'
208
188
  - - ">="
209
189
  - !ruby/object:Gem::Version
210
- version: 1.22.2
190
+ version: 3.1.7
211
191
  - !ruby/object:Gem::Dependency
212
- name: sinatra
192
+ name: rubocop
213
193
  requirement: !ruby/object:Gem::Requirement
214
194
  requirements:
215
- - - "~>"
216
- - !ruby/object:Gem::Version
217
- version: '1.4'
218
- - - ">="
195
+ - - '='
219
196
  - !ruby/object:Gem::Version
220
- version: 1.4.7
197
+ version: 0.47.1
221
198
  type: :development
222
199
  prerelease: false
223
200
  version_requirements: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - '='
203
+ - !ruby/object:Gem::Version
204
+ version: 0.47.1
205
+ - !ruby/object:Gem::Dependency
206
+ name: simplecov
207
+ requirement: !ruby/object:Gem::Requirement
224
208
  requirements:
225
209
  - - "~>"
226
210
  - !ruby/object:Gem::Version
227
- version: '1.4'
228
- - - ">="
211
+ version: '0.15'
212
+ type: :development
213
+ prerelease: false
214
+ version_requirements: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - "~>"
229
217
  - !ruby/object:Gem::Version
230
- version: 1.4.7
218
+ version: '0.15'
231
219
  - !ruby/object:Gem::Dependency
232
- name: rubocop
220
+ name: sinatra
233
221
  requirement: !ruby/object:Gem::Requirement
234
222
  requirements:
235
- - - '='
223
+ - - "~>"
236
224
  - !ruby/object:Gem::Version
237
- version: 0.47.1
225
+ version: '1.4'
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: 1.4.7
238
229
  type: :development
239
230
  prerelease: false
240
231
  version_requirements: !ruby/object:Gem::Requirement
241
232
  requirements:
242
- - - '='
233
+ - - "~>"
243
234
  - !ruby/object:Gem::Version
244
- version: 0.47.1
235
+ version: '1.4'
236
+ - - ">="
237
+ - !ruby/object:Gem::Version
238
+ version: 1.4.7
245
239
  - !ruby/object:Gem::Dependency
246
- name: simplecov
240
+ name: webmock
247
241
  requirement: !ruby/object:Gem::Requirement
248
242
  requirements:
249
243
  - - "~>"
250
244
  - !ruby/object:Gem::Version
251
- version: '0.15'
245
+ version: '1.22'
246
+ - - ">="
247
+ - !ruby/object:Gem::Version
248
+ version: 1.22.2
252
249
  type: :development
253
250
  prerelease: false
254
251
  version_requirements: !ruby/object:Gem::Requirement
255
252
  requirements:
256
253
  - - "~>"
257
254
  - !ruby/object:Gem::Version
258
- version: '0.15'
255
+ version: '1.22'
256
+ - - ">="
257
+ - !ruby/object:Gem::Version
258
+ version: 1.22.2
259
259
  description:
260
260
  email:
261
261
  - genmadrid@gmail.com
@@ -281,6 +281,7 @@ files:
281
281
  - lib/mifiel/document.rb
282
282
  - lib/mifiel/errors.rb
283
283
  - lib/mifiel/template.rb
284
+ - lib/mifiel/user.rb
284
285
  - lib/mifiel/version.rb
285
286
  - mifiel-ruby-api-client.sublime-project
286
287
  - mifiel.gemspec
@@ -291,6 +292,7 @@ files:
291
292
  - spec/mifiel/certificate_spec.rb
292
293
  - spec/mifiel/document_spec.rb
293
294
  - spec/mifiel/template_spec.rb
295
+ - spec/mifiel/user_spec.rb
294
296
  - spec/spec_helper.rb
295
297
  - spec/support/fake_mifiel.rb
296
298
  homepage: https://www.mifiel.com
@@ -325,5 +327,6 @@ test_files:
325
327
  - spec/mifiel/certificate_spec.rb
326
328
  - spec/mifiel/document_spec.rb
327
329
  - spec/mifiel/template_spec.rb
330
+ - spec/mifiel/user_spec.rb
328
331
  - spec/spec_helper.rb
329
332
  - spec/support/fake_mifiel.rb