omniauth-varejonline 0.0.1

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.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.gitignore +17 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +22 -0
  6. data/README.md +47 -0
  7. data/Rakefile +2 -0
  8. data/exemplo/.gitignore +15 -0
  9. data/exemplo/Gemfile +40 -0
  10. data/exemplo/README.rdoc +261 -0
  11. data/exemplo/Rakefile +7 -0
  12. data/exemplo/app/assets/images/rails.png +0 -0
  13. data/exemplo/app/assets/javascripts/application.js +15 -0
  14. data/exemplo/app/assets/javascripts/home.js.coffee +3 -0
  15. data/exemplo/app/assets/stylesheets/application.css +13 -0
  16. data/exemplo/app/assets/stylesheets/home.css.scss +3 -0
  17. data/exemplo/app/controllers/application_controller.rb +3 -0
  18. data/exemplo/app/controllers/home_controller.rb +6 -0
  19. data/exemplo/app/controllers/sessions_controller.rb +12 -0
  20. data/exemplo/app/helpers/application_helper.rb +2 -0
  21. data/exemplo/app/helpers/home_helper.rb +2 -0
  22. data/exemplo/app/mailers/.gitkeep +0 -0
  23. data/exemplo/app/models/.gitkeep +0 -0
  24. data/exemplo/app/views/home/index.html.erb +1 -0
  25. data/exemplo/app/views/layouts/application.html.erb +14 -0
  26. data/exemplo/config.ru +4 -0
  27. data/exemplo/config/application.rb +62 -0
  28. data/exemplo/config/boot.rb +6 -0
  29. data/exemplo/config/database.yml +25 -0
  30. data/exemplo/config/environment.rb +5 -0
  31. data/exemplo/config/environments/development.rb +37 -0
  32. data/exemplo/config/environments/production.rb +67 -0
  33. data/exemplo/config/environments/test.rb +37 -0
  34. data/exemplo/config/initializers/backtrace_silencers.rb +7 -0
  35. data/exemplo/config/initializers/inflections.rb +15 -0
  36. data/exemplo/config/initializers/mime_types.rb +5 -0
  37. data/exemplo/config/initializers/omniauth.rb +7 -0
  38. data/exemplo/config/initializers/secret_token.rb +7 -0
  39. data/exemplo/config/initializers/session_store.rb +8 -0
  40. data/exemplo/config/initializers/wrap_parameters.rb +14 -0
  41. data/exemplo/config/locales/en.yml +5 -0
  42. data/exemplo/config/routes.rb +7 -0
  43. data/exemplo/db/seeds.rb +7 -0
  44. data/exemplo/lib/assets/.gitkeep +0 -0
  45. data/exemplo/lib/tasks/.gitkeep +0 -0
  46. data/exemplo/log/.gitkeep +0 -0
  47. data/exemplo/public/404.html +26 -0
  48. data/exemplo/public/422.html +26 -0
  49. data/exemplo/public/500.html +25 -0
  50. data/exemplo/public/favicon.ico +0 -0
  51. data/exemplo/public/robots.txt +5 -0
  52. data/exemplo/script/rails +6 -0
  53. data/exemplo/test/fixtures/.gitkeep +0 -0
  54. data/exemplo/test/functional/.gitkeep +0 -0
  55. data/exemplo/test/functional/home_controller_test.rb +9 -0
  56. data/exemplo/test/integration/.gitkeep +0 -0
  57. data/exemplo/test/performance/browsing_test.rb +12 -0
  58. data/exemplo/test/test_helper.rb +13 -0
  59. data/exemplo/test/unit/.gitkeep +0 -0
  60. data/exemplo/test/unit/helpers/home_helper_test.rb +4 -0
  61. data/exemplo/vendor/assets/javascripts/.gitkeep +0 -0
  62. data/exemplo/vendor/assets/stylesheets/.gitkeep +0 -0
  63. data/exemplo/vendor/plugins/.gitkeep +0 -0
  64. data/lib/.DS_Store +0 -0
  65. data/lib/omniauth-varejonline.rb +2 -0
  66. data/lib/omniauth-varejonline/version.rb +5 -0
  67. data/lib/omniauth/strategies/varejonline.rb +85 -0
  68. data/lib/omniauth/varejonline.rb +1 -0
  69. data/omniauth-varejonline.gemspec +21 -0
  70. metadata +142 -0
File without changes
File without changes
File without changes
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
File without changes
File without changes
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ class HomeControllerTest < ActionController::TestCase
4
+ test "should get index" do
5
+ get :index
6
+ assert_response :success
7
+ end
8
+
9
+ end
File without changes
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+ require 'rails/performance_test_help'
3
+
4
+ class BrowsingTest < ActionDispatch::PerformanceTest
5
+ # Refer to the documentation for all available options
6
+ # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
7
+ # :output => 'tmp/performance', :formats => [:flat] }
8
+
9
+ def test_homepage
10
+ get '/'
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7
+ #
8
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
+ # -- they do not yet inherit this setting
10
+ fixtures :all
11
+
12
+ # Add more helper methods to be used by all tests here...
13
+ end
File without changes
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class HomeHelperTest < ActionView::TestCase
4
+ end
File without changes
File without changes
File without changes
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,2 @@
1
+ require "omniauth-varejonline/version"
2
+ require "omniauth/varejonline"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Varejonline
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,85 @@
1
+ require 'omniauth/strategies/oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Varejonline < OmniAuth::Strategies::OAuth2
6
+
7
+ # Possible scopes: userinfo.email,userinfo.profile,plus.me
8
+ DEFAULT_SCOPE = "all"
9
+
10
+ option :name, 'varejonline'
11
+ option :authorize_options, [:app_id, :redirect_uri]
12
+ option :provider_ignores_state, :true
13
+
14
+ option :client_options, {
15
+ :site => 'https://integrador.varejonline.com.br',
16
+ :authorize_url => '/apps/oauth/authorization?response_type=code',
17
+ :token_url => '/apps/oauth/token'
18
+ }
19
+
20
+ option :token_params, {
21
+ :formato => :json
22
+ }
23
+
24
+ def request_phase
25
+ redirect client.auth_code.authorize_url({:redirect_uri => options.redirect_uri }.merge(options.authorize_params)).gsub("client_id", "app_id")
26
+ end
27
+
28
+ info do
29
+ prune!({
30
+ :cnpj_empresa => raw_info['cnpj_empresa'],
31
+ :id_terceiro => raw_info['id_terceiro'],
32
+ :nome_terceiro => raw_info['nome_terceiro']
33
+ })
34
+ end
35
+
36
+ def raw_info
37
+ @raw_info ||= build_access_token
38
+ end
39
+
40
+ private
41
+
42
+ def prune!(hash)
43
+ hash.delete_if do |_, value|
44
+ prune!(value) if value.is_a?(Hash)
45
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ module OAuth2
53
+ class Client
54
+ def get_token(params, access_token_opts={})
55
+ opts = {:raise_errors => options[:raise_errors], :parse => params.delete(:parse)}
56
+ if options[:token_method] == :post
57
+ headers = params.delete(:headers)
58
+
59
+ if params[:formato] == :json
60
+ opts[:body] = params.to_json
61
+ opts[:headers] = {'Content-Type' => 'application/json'}
62
+ else
63
+ opts[:body] = params
64
+ opts[:headers] = {'Content-Type' => 'application/x-www-form-urlencoded'}
65
+ end
66
+
67
+ opts[:headers].merge!(headers) if headers
68
+ else
69
+ opts[:params] = params
70
+ end
71
+
72
+ response = request(options[:token_method], token_url, opts)
73
+ raise Error.new(response) if options[:raise_errors] && !(response.parsed.is_a?(Hash) && response.parsed['access_token'])
74
+ AccessToken.from_hash(self, response.parsed.merge(access_token_opts))
75
+ end
76
+ end
77
+
78
+ module Strategy
79
+ class Base
80
+ def client_params
81
+ {'app_id' => @client.id, 'app_secret' => @client.secret, 'client_id' => @client.id, 'client_secret' => @client.secret}
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1 @@
1
+ require 'omniauth/strategies/varejonline'
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-varejonline/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.add_dependency 'omniauth', '~> 1.0'
6
+
7
+ gem.authors = ["João Paulo", "Coyô Software"]
8
+ gem.email = ["jpjcjbr@gmail.com", "contato@coyo.com.br"]
9
+ gem.description = %q{Gem criada para facilitar a integração com as API's do Varejonline}
10
+ gem.summary = %q{Gem criada para facilitar a integração com as API's do Varejonline}
11
+ gem.homepage = ""
12
+
13
+ gem.files = `git ls-files`.split($\)
14
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.name = "omniauth-varejonline"
17
+ gem.require_paths = ["lib"]
18
+ gem.version = Omniauth::Varejonline::VERSION
19
+
20
+ gem.add_runtime_dependency 'omniauth-oauth2'
21
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-varejonline
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - João Paulo
8
+ - Coyô Software
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-11-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: omniauth-oauth2
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: Gem criada para facilitar a integração com as API's do Varejonline
43
+ email:
44
+ - jpjcjbr@gmail.com
45
+ - contato@coyo.com.br
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".DS_Store"
51
+ - ".gitignore"
52
+ - Gemfile
53
+ - LICENSE
54
+ - README.md
55
+ - Rakefile
56
+ - exemplo/.gitignore
57
+ - exemplo/Gemfile
58
+ - exemplo/README.rdoc
59
+ - exemplo/Rakefile
60
+ - exemplo/app/assets/images/rails.png
61
+ - exemplo/app/assets/javascripts/application.js
62
+ - exemplo/app/assets/javascripts/home.js.coffee
63
+ - exemplo/app/assets/stylesheets/application.css
64
+ - exemplo/app/assets/stylesheets/home.css.scss
65
+ - exemplo/app/controllers/application_controller.rb
66
+ - exemplo/app/controllers/home_controller.rb
67
+ - exemplo/app/controllers/sessions_controller.rb
68
+ - exemplo/app/helpers/application_helper.rb
69
+ - exemplo/app/helpers/home_helper.rb
70
+ - exemplo/app/mailers/.gitkeep
71
+ - exemplo/app/models/.gitkeep
72
+ - exemplo/app/views/home/index.html.erb
73
+ - exemplo/app/views/layouts/application.html.erb
74
+ - exemplo/config.ru
75
+ - exemplo/config/application.rb
76
+ - exemplo/config/boot.rb
77
+ - exemplo/config/database.yml
78
+ - exemplo/config/environment.rb
79
+ - exemplo/config/environments/development.rb
80
+ - exemplo/config/environments/production.rb
81
+ - exemplo/config/environments/test.rb
82
+ - exemplo/config/initializers/backtrace_silencers.rb
83
+ - exemplo/config/initializers/inflections.rb
84
+ - exemplo/config/initializers/mime_types.rb
85
+ - exemplo/config/initializers/omniauth.rb
86
+ - exemplo/config/initializers/secret_token.rb
87
+ - exemplo/config/initializers/session_store.rb
88
+ - exemplo/config/initializers/wrap_parameters.rb
89
+ - exemplo/config/locales/en.yml
90
+ - exemplo/config/routes.rb
91
+ - exemplo/db/seeds.rb
92
+ - exemplo/lib/assets/.gitkeep
93
+ - exemplo/lib/tasks/.gitkeep
94
+ - exemplo/log/.gitkeep
95
+ - exemplo/public/404.html
96
+ - exemplo/public/422.html
97
+ - exemplo/public/500.html
98
+ - exemplo/public/favicon.ico
99
+ - exemplo/public/robots.txt
100
+ - exemplo/script/rails
101
+ - exemplo/test/fixtures/.gitkeep
102
+ - exemplo/test/functional/.gitkeep
103
+ - exemplo/test/functional/home_controller_test.rb
104
+ - exemplo/test/integration/.gitkeep
105
+ - exemplo/test/performance/browsing_test.rb
106
+ - exemplo/test/test_helper.rb
107
+ - exemplo/test/unit/.gitkeep
108
+ - exemplo/test/unit/helpers/home_helper_test.rb
109
+ - exemplo/vendor/assets/javascripts/.gitkeep
110
+ - exemplo/vendor/assets/stylesheets/.gitkeep
111
+ - exemplo/vendor/plugins/.gitkeep
112
+ - lib/.DS_Store
113
+ - lib/omniauth-varejonline.rb
114
+ - lib/omniauth-varejonline/version.rb
115
+ - lib/omniauth/strategies/varejonline.rb
116
+ - lib/omniauth/varejonline.rb
117
+ - omniauth-varejonline.gemspec
118
+ homepage: ''
119
+ licenses: []
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.4.6
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Gem criada para facilitar a integração com as API's do Varejonline
141
+ test_files: []
142
+ has_rdoc: