-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
73 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Mifiel | ||
class User < Mifiel::Base | ||
post :setup_widget, '/users/setup-widget' | ||
|
||
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize | ||
def self.setup_widget(args) | ||
email = args[:email] | ||
tax_id = args[:tax_id] | ||
callback_url = args[:callback_url] | ||
|
||
raise ArgumentError, 'Email must be provided' unless email | ||
raise ArgumentError, 'Tax id must be provided' unless tax_id | ||
rest_request = RestClient::Request.new( | ||
url: "#{Mifiel.config.base_url}/users/setup-widget", | ||
method: :post, | ||
payload: { | ||
email: email, | ||
tax_id: tax_id, | ||
callback_url: callback_url | ||
}, | ||
ssl_version: 'SSLv23' | ||
) | ||
req = ApiAuth.sign!(rest_request, Mifiel.config.app_id, Mifiel.config.app_secret) | ||
Mifiel::User.new(JSON.parse(req.execute)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
describe Mifiel::User do | ||
describe '#setup_widget' do | ||
let(:user) do | ||
Mifiel::User.setup_widget( | ||
email: 'user@email.com', | ||
tax_id: 'AAA010101AAA', | ||
callback_url: 'http://some-callback.url/mifiel' | ||
) | ||
end | ||
|
||
it { expect(user.success).to be_truthy } | ||
it { expect(user.widget_id).to_not be_nil } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters