omniauth-lightspeed 1.0.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6d2f6577a508875cb99912188016e13c1cd24677
4
+ data.tar.gz: c3ecfe651c2acd84cf715d5ca49da42153ccfae4
5
+ SHA512:
6
+ metadata.gz: 34fe17b94882686d224791fc752fc310014bd5dd0943330f0507ebd78ca94de2f7ce2ac5d06854bca4e0505b5f5ec0edbf17b256ee44e4c958cb8a745ce7ce27
7
+ data.tar.gz: 689e808a6109d7fe4620d9f320871bb4353d3e9f99f3afa1e336bc97826892ca81b29c709621d55772fc83a66587d21224f22c7d3ab08db8796e13c8d273ebcd
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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
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.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-lightspeed.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # OmniAuth Lightspeed Strategy
2
+
3
+ An OmniAuth Lightspeed Strategy. Does what it says on the box.
4
+
5
+ ## Usage
6
+
7
+ ```ruby
8
+ Rails.application.config.middleware.use OmniAuth::Builder do
9
+ provider :lightspeed, ENV['LIGHTSPEED_CLIENT_ID'], ENV['LIGHTSPEED_CLIENT_SECRET'], scope: 'employee:all'
10
+ end
11
+ ```
12
+
13
+ ## TODO
14
+
15
+ * Support situation where an access token can have access to more than one account.
16
+ * Determine if the above is even possible.
17
+
18
+ ## I found a bug!
19
+
20
+ 1. Pull requests are welcome.
21
+ 2. OR: Provide steps to reproduce the bug in a new issue.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth/lightspeed"
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,8 @@
1
+ require "omniauth/lightspeed/version"
2
+ require "omniauth/lightspeed/strategy"
3
+
4
+ module OmniAuth
5
+ module Lightspeed
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,42 @@
1
+ require "omniauth/strategies/oauth2"
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Lightspeed < OmniAuth::Strategies::OAuth2
6
+ option :name, "lightspeed"
7
+
8
+ option :client_options, {
9
+ site: "https://cloud.merchantos.com",
10
+ authorize_url: "/oauth/authorize.php",
11
+ token_url: "/oauth/access_token.php",
12
+ # header_format: 'OAuth %s'
13
+ }
14
+
15
+ uid { raw_info[:accountID] }
16
+
17
+
18
+ info do
19
+ { :name => raw_info[:name] }
20
+ end
21
+
22
+ def build_access_token
23
+ access_token = super
24
+ # TODO: is there a better way to specify this?
25
+ access_token.options[:header_format] = "OAuth %s"
26
+ access_token
27
+ end
28
+
29
+
30
+ def raw_info
31
+ @raw_info ||= begin
32
+ account_xml = access_token.get('/API/Account').body
33
+ account = Nokogiri::XML.parse(account_xml).css('Account:first')
34
+ {
35
+ accountID: account.css("accountID").text,
36
+ name: account.css("name").text
37
+ }
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Lightspeed
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/lightspeed/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-lightspeed"
8
+ spec.version = Omniauth::Lightspeed::VERSION
9
+ spec.authors = ["Ryan Bigg"]
10
+ spec.email = ["git@ryanbigg.com"]
11
+
12
+ spec.summary = %q{OmniAuth strategy for Lightspeed.}
13
+ spec.description = %q{OmniAuth strategy for Lightspeed.}
14
+ spec.homepage = "https://github.com/radar/omniauth-lightspeed"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency "omniauth-oauth2"
20
+ spec.add_dependency "nokogiri"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-lightspeed
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Bigg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
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
+ description: OmniAuth strategy for Lightspeed.
84
+ email:
85
+ - git@ryanbigg.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
98
+ - lib/omniauth/lightspeed.rb
99
+ - lib/omniauth/lightspeed/strategy.rb
100
+ - lib/omniauth/lightspeed/version.rb
101
+ - omniauth-lightspeed.gemspec
102
+ homepage: https://github.com/radar/omniauth-lightspeed
103
+ licenses: []
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.4.8
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: OmniAuth strategy for Lightspeed.
125
+ test_files: []