help_provas_api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitattributes ADDED
@@ -0,0 +1,22 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
3
+
4
+ # Custom for Visual Studio
5
+ *.cs diff=csharp
6
+ *.sln merge=union
7
+ *.csproj merge=union
8
+ *.vbproj merge=union
9
+ *.fsproj merge=union
10
+ *.dbproj merge=union
11
+
12
+ # Standard to msysgit
13
+ *.doc diff=astextplain
14
+ *.DOC diff=astextplain
15
+ *.docx diff=astextplain
16
+ *.DOCX diff=astextplain
17
+ *.dot diff=astextplain
18
+ *.DOT diff=astextplain
19
+ *.pdf diff=astextplain
20
+ *.PDF diff=astextplain
21
+ *.rtf diff=astextplain
22
+ *.RTF diff=astextplain
data/.gitignore ADDED
@@ -0,0 +1,163 @@
1
+ #################
2
+ ## Eclipse
3
+ #################
4
+
5
+ *.pydevproject
6
+ .project
7
+ .metadata
8
+ bin/
9
+ tmp/
10
+ *.tmp
11
+ *.bak
12
+ *.swp
13
+ *~.nib
14
+ local.properties
15
+ .classpath
16
+ .settings/
17
+ .loadpath
18
+
19
+ # External tool builders
20
+ .externalToolBuilders/
21
+
22
+ # Locally stored "Eclipse launch configurations"
23
+ *.launch
24
+
25
+ # CDT-specific
26
+ .cproject
27
+
28
+ # PDT-specific
29
+ .buildpath
30
+
31
+
32
+ #################
33
+ ## Visual Studio
34
+ #################
35
+
36
+ ## Ignore Visual Studio temporary files, build results, and
37
+ ## files generated by popular Visual Studio add-ons.
38
+
39
+ # User-specific files
40
+ *.suo
41
+ *.user
42
+ *.sln.docstates
43
+
44
+ # Build results
45
+ [Dd]ebug/
46
+ [Rr]elease/
47
+ *_i.c
48
+ *_p.c
49
+ *.ilk
50
+ *.meta
51
+ *.obj
52
+ *.pch
53
+ *.pdb
54
+ *.pgc
55
+ *.pgd
56
+ *.rsp
57
+ *.sbr
58
+ *.tlb
59
+ *.tli
60
+ *.tlh
61
+ *.tmp
62
+ *.vspscc
63
+ .builds
64
+ *.dotCover
65
+
66
+ ## TODO: If you have NuGet Package Restore enabled, uncomment this
67
+ #packages/
68
+
69
+ # Visual C++ cache files
70
+ ipch/
71
+ *.aps
72
+ *.ncb
73
+ *.opensdf
74
+ *.sdf
75
+
76
+ # Visual Studio profiler
77
+ *.psess
78
+ *.vsp
79
+
80
+ # ReSharper is a .NET coding add-in
81
+ _ReSharper*
82
+
83
+ # Installshield output folder
84
+ [Ee]xpress
85
+
86
+ # DocProject is a documentation generator add-in
87
+ DocProject/buildhelp/
88
+ DocProject/Help/*.HxT
89
+ DocProject/Help/*.HxC
90
+ DocProject/Help/*.hhc
91
+ DocProject/Help/*.hhk
92
+ DocProject/Help/*.hhp
93
+ DocProject/Help/Html2
94
+ DocProject/Help/html
95
+
96
+ # Click-Once directory
97
+ publish
98
+
99
+ # Others
100
+ [Bb]in
101
+ [Oo]bj
102
+ sql
103
+ TestResults
104
+ *.Cache
105
+ ClientBin
106
+ stylecop.*
107
+ ~$*
108
+ *.dbmdl
109
+ Generated_Code #added for RIA/Silverlight projects
110
+
111
+ # Backup & report files from converting an old project file to a newer
112
+ # Visual Studio version. Backup files are not needed, because we have git ;-)
113
+ _UpgradeReport_Files/
114
+ Backup*/
115
+ UpgradeLog*.XML
116
+
117
+
118
+
119
+ ############
120
+ ## Windows
121
+ ############
122
+
123
+ # Windows image file caches
124
+ Thumbs.db
125
+
126
+ # Folder config file
127
+ Desktop.ini
128
+
129
+
130
+ #############
131
+ ## Python
132
+ #############
133
+
134
+ *.py[co]
135
+
136
+ # Packages
137
+ *.egg
138
+ *.egg-info
139
+ dist
140
+ build
141
+ eggs
142
+ parts
143
+ bin
144
+ var
145
+ sdist
146
+ develop-eggs
147
+ .installed.cfg
148
+
149
+ # Installer logs
150
+ pip-log.txt
151
+
152
+ # Unit test / coverage reports
153
+ .coverage
154
+ .tox
155
+
156
+ #Translations
157
+ *.mo
158
+
159
+ #Mr Developer
160
+ .mr.developer.cfg
161
+
162
+ # Mac crap
163
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+ #interface to your soap service
3
+ gemspec
4
+
5
+ gem "rest-client"
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler"
data/Readme.md ADDED
@@ -0,0 +1,90 @@
1
+ #Help Provas Api
2
+
3
+ Integração com Help Provas
4
+
5
+ ##Funcionalidades
6
+
7
+ * Gerar voucher
8
+ * Resgatar voucher
9
+ * Cancelar voucher
10
+ * Gerar acesso
11
+
12
+ ##Utilização
13
+ ```ruby
14
+ gem install help_provas_api
15
+ ```
16
+
17
+ ###Rails
18
+ ```ruby
19
+ rails g help_provas_api:install
20
+ ```
21
+ Este comando irá gerar um arquivo config/initializers/help_provas_api.rb onde você deverá informar os dados para os ambientes de desenvolvimento e produção.
22
+
23
+ config/initializers/help_provas_api.rb
24
+ ```ruby
25
+ HelpProvasApi.setup do |config|
26
+ env = Rails.env
27
+ if(env == "production")
28
+ config.environment = :production
29
+ config.token = ""
30
+ config.version = ""
31
+ else
32
+ config.environment = :development
33
+ config.token = ""
34
+ config.version = ""
35
+ end
36
+ end
37
+ ```
38
+
39
+ ###Exemplo de utilização
40
+ Verifique os campos de retorno conforme o manual que lhe foi concedido.
41
+
42
+ Gerar voucher:
43
+ ```ruby
44
+ voucher = HelpProvasApi::Voucher.new
45
+ response = voucher.generate(product_code,plan_code)
46
+ puts response["CodigoRetorno"]
47
+ ```
48
+
49
+ Resgatar voucher:
50
+ ```ruby
51
+ voucher = HelpProvasApi::Voucher.new
52
+ response = voucher.reedem(voucher_code, name, email, password, phone, plan_code)
53
+ puts response["CodigoRetorno"]
54
+ ```
55
+
56
+ Cancelar voucher:
57
+ ```ruby
58
+ voucher = HelpProvasApi::Voucher.new
59
+ response = voucher.cancel(voucher_code)
60
+ puts response["CodigoRetorno"]
61
+ ```
62
+
63
+ Gerar acesso:
64
+ ```ruby
65
+ voucher = HelpProvasApi::Voucher.new
66
+ response = voucher.access(product_code, name, email, password, phone, plan_code)
67
+ puts response["CodigoRetorno"]
68
+ ```
69
+
70
+ ##Licensa
71
+ Copyright(c)2013 Tarik Boschi.
72
+
73
+ A permissão é concedida, de forma gratuita, para qualquer pessoa que obtenha
74
+ parceria com a Help Provas possa fazer uma cópia deste software e arquivos,
75
+ para lidar com o Software sem restrição, incluindo
76
+ sem limitação, os direitos de usar, copiar, modificar, mesclar, publicar,
77
+ distribuir, sublicenciar e / ou vender cópias do Software, e
78
+ permitir às pessoas a quem o Software é fornecido a fazê-lo, desde que
79
+ nas seguintes condições:
80
+
81
+ O aviso de copyright acima e este aviso de permissão devem ser
82
+ incluído em todas as cópias ou partes substanciais do Software.
83
+
84
+ O SOFTWARE É FORNECIDO "COMO ESTÁ", SEM GARANTIA DE QUALQUER TIPO,
85
+ EXPRESSA OU IMPLÍCITA, INCLUINDO, SEM LIMITAÇÃO, AS GARANTIAS DE
86
+ COMERCIALIZAÇÃO, ADEQUAÇÃO A UM DETERMINADO FIM E LEGALIDADE. EM
87
+ NENHUM CASO OS AUTORES OU DETENTORES DE DIREITOS AUTORAIS SÃO
88
+ RESPONSÁVEIS POR QUALQUER RECLAMAÇÃO, DANOS OU OUTRAS RESPONSABILIDADES,
89
+ SEJA EM UMA AÇÃO DE CONTRATO, OU DE OUTRA FORMA, DECORRENTES DE OU CONEXÃO
90
+ COM O SOFTWARE OU O USO OU OUTRA APLICAÇÃO DO SOFTWARE.
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ require "help_provas_api/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "help_provas_api"
8
+ s.version = HelpProvasApi::VERSION
9
+ s.authors = ["Tarik"]
10
+ s.email = ["tarik@boschi.com.br"]
11
+ s.homepage = "https://github.com/tarikboschi/help_provas_api"
12
+ s.summary = %q{Integração API Help Provas}
13
+ s.description = %q{GEM para integração com a API da Help Provas}
14
+
15
+ s.rubyforge_project = "help_provas_api"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency 'rest-client'
23
+
24
+ # specify any dependencies here; for example:
25
+ # s.add_development_dependency "rspec"
26
+ # s.add_runtime_dependency "rest-client"
27
+ end
@@ -0,0 +1,13 @@
1
+ module HelpProvasApi
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates",__FILE__)
5
+
6
+ desc "Cria o initializer da API Help Provas"
7
+
8
+ def copy_initializer
9
+ template "help_provas_api.rb", "config/initializers/help_provas_api.rb"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+ # Use esse arquivo para configurar a integração com a Cresca Brasil.
3
+ HelpProvasApi.setup do |config|
4
+ env = Rails.env
5
+ if(env == "production")
6
+ config.environment = :production
7
+ config.token = ""
8
+ config.version = ""
9
+ else
10
+ config.environment = :development
11
+ config.token = ""
12
+ config.version = ""
13
+ end
14
+ end
@@ -0,0 +1,30 @@
1
+ require 'rest-client'
2
+ require 'active_support/core_ext/class/attribute_accessors'
3
+ require 'active_support/core_ext/module/attribute_accessors'
4
+ require 'active_support/core_ext/hash'
5
+ require 'builder'
6
+ require 'json'
7
+ [:version,:voucher].each { |lib| require "help_provas_api/#{lib}" }
8
+
9
+ module HelpProvasApi
10
+ class Production
11
+ URL = "http://api.helpprovas.com.br/Voucher.svc"
12
+ end
13
+
14
+ class Development
15
+ URL = "http://apisandbox.helpprovas.com.br/Voucher.svc"
16
+ end
17
+
18
+ @@environment = :development
19
+ mattr_accessor :environment
20
+ @@token = ""
21
+ mattr_accessor :token
22
+ @@version = ""
23
+ mattr_accessor :version
24
+
25
+ def self.setup
26
+ yield self
27
+ end
28
+
29
+ class MissingArgumentError < StandardError; end
30
+ end
@@ -0,0 +1,3 @@
1
+ module HelpProvasApi
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,43 @@
1
+ #encoding: utf-8
2
+ module HelpProvasApi
3
+ class Voucher
4
+ attr_reader :environment
5
+ def initialize
6
+ @environment = eval(HelpProvasApi.environment.to_s.capitalize)
7
+ end
8
+
9
+ #cancela voucher
10
+ def cancel(voucher_code)
11
+ uri = "#{self.environment::URL}/Cancelar/#{HelpProvasApi.token}/#{HelpProvasApi.version}/"
12
+ uri += "#{voucher_code}"
13
+ request uri
14
+ end
15
+
16
+ #gera o voucher
17
+ def generate(product_code, plan_code)
18
+ uri = "#{self.environment::URL}/Gerar/#{HelpProvasApi.token}/#{HelpProvasApi.version}/"
19
+ uri += "#{product_code}/#{plan_code}"
20
+ request uri
21
+ end
22
+
23
+ #gera acesso do cliente no sistema
24
+ def access(product_code, name, email, password, phone, plan_code)
25
+ uri = "#{self.environment::URL}/GerarAcesso/#{HelpProvasApi.token}/#{HelpProvasApi.version}/"
26
+ uri += "#{product_code}/#{name}/#{email}/#{password}/#{phone}/#{plan_code}"
27
+ request uri
28
+ end
29
+
30
+ #ativa o voucher
31
+ def redeem(voucher_code, name, email, password, phone, plan_code)
32
+ uri = "#{self.environment::URL}/Resgatar/#{HelpProvasApi.token}/#{HelpProvasApi.version}/"
33
+ uri += "#{voucher_code}/#{name}/#{email}/#{password}/#{phone}"
34
+ request uri
35
+ end
36
+
37
+ private
38
+ def request(uri)
39
+ resp = RestClient.get uri
40
+ JSON.parse(resp)
41
+ end
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: help_provas_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tarik
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rest-client
16
+ requirement: &19910856 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *19910856
25
+ description: GEM para integração com a API da Help Provas
26
+ email:
27
+ - tarik@boschi.com.br
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitattributes
33
+ - .gitignore
34
+ - Gemfile
35
+ - Rakefile
36
+ - Readme.md
37
+ - help_provas_api.gemspec
38
+ - lib/generators/help_provas_api/install_generator.rb
39
+ - lib/generators/templates/help_provas_api.rb
40
+ - lib/help_provas_api.rb
41
+ - lib/help_provas_api/version.rb
42
+ - lib/help_provas_api/voucher.rb
43
+ homepage: https://github.com/tarikboschi/help_provas_api
44
+ licenses: []
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project: help_provas_api
63
+ rubygems_version: 1.8.16
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: Integração API Help Provas
67
+ test_files: []