run_signup_api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1f9c8c3b7ca3c6035f66806d78c827ceba4dac27766fcb22ad3cc489464be9c3
4
+ data.tar.gz: 0ed2c6afdfa65660a565ddc01deb3f3cdedff0749d9f3e4e75d53fceb0551df6
5
+ SHA512:
6
+ metadata.gz: faa276e7f6f3df6b21f571476a3bd73cac8837dcfb99f84ee16b597589a630181f9d298dd43b9617ad0945791f0e5135a6b995faeff1a0b780c645db26b5fb17
7
+ data.tar.gz: 58a5605e56100c01c46d1b51ddcdea0dcd955d0ee2e96f797d666a4e28f843535261e4be8e243c67fd355397c2cdb4841e11f234d8f48bcc5ef7d846c1983169
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,42 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ run_signup_api (0.0.1)
5
+ httparty
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.3)
11
+ dotenv (2.7.5)
12
+ httparty (0.17.3)
13
+ mime-types (~> 3.0)
14
+ multi_xml (>= 0.5.2)
15
+ mime-types (3.3.1)
16
+ mime-types-data (~> 3.2015)
17
+ mime-types-data (3.2019.1009)
18
+ multi_xml (0.6.0)
19
+ rspec (3.9.0)
20
+ rspec-core (~> 3.9.0)
21
+ rspec-expectations (~> 3.9.0)
22
+ rspec-mocks (~> 3.9.0)
23
+ rspec-core (3.9.1)
24
+ rspec-support (~> 3.9.1)
25
+ rspec-expectations (3.9.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.9.0)
28
+ rspec-mocks (3.9.1)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.9.0)
31
+ rspec-support (3.9.2)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ dotenv (~> 2.7)
38
+ rspec (~> 3.9)
39
+ run_signup_api!
40
+
41
+ BUNDLED WITH
42
+ 1.17.2
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT LICENSE
2
+
3
+ Copyright (c) 2020 dbwinger <dbwinger@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ ## Console
2
+ ```
3
+ ENV=development bin/console
4
+ ```
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "run_signup_api"
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(__FILE__)
@@ -0,0 +1,5 @@
1
+ require 'ostruct'
2
+
3
+ module RunSignup
4
+ class Race < OpenStruct; end;
5
+ end
@@ -0,0 +1,10 @@
1
+ if ENV['ENV'] == 'development'
2
+ require 'dotenv/load'
3
+ end
4
+ require 'run_signup_api/version'
5
+ require 'run_signup/race'
6
+ require 'run_signup_api/client'
7
+
8
+ module RunSignupApi
9
+ class Error < StandardError; end
10
+ end
@@ -0,0 +1,74 @@
1
+ require 'httparty'
2
+
3
+ module RunSignupApi
4
+ class Client
5
+ include HTTParty
6
+
7
+ BASE_URL = "https://runsignup.com/rest"
8
+
9
+ def initialize api_key: ENV['RUN_SIGNUP_API_KEY'], api_secret: ENV['RUN_SIGNUP_API_SECRET'], response_format: :json
10
+ @api_key, @api_secret, @response_format = api_key, api_secret, response_format
11
+ end
12
+
13
+ # Params used by all API calls
14
+ def default_params
15
+ {
16
+ api_key: @api_key,
17
+ api_secret: @api_secret,
18
+ format: @response_format
19
+ }
20
+ end
21
+
22
+ def get_races **opts
23
+ # Response in format
24
+ # {
25
+ # "races": [{
26
+ # "race": {
27
+ # "race_id": 67504,
28
+ # "name": "124th Boston Marathon: Fundraising for The Angel Fund, Supported by the Sharon Timlin Race to Cure ALS",
29
+ # "last_date": "04\/15\/2019",
30
+ # ...
31
+ # }
32
+ # },
33
+ # "race": {
34
+ # "race_id": 67505,
35
+ # "name": "Another race",
36
+ # "last_date": "04\/16\/2019",
37
+ # ...
38
+ # }
39
+ # }]
40
+ # }
41
+ call_api('/races', opts)['races'].map do |race|
42
+ RunSignup::Race.new(race['race'])
43
+ end
44
+ end
45
+
46
+ # RunSignup::Client.new.get_race(1, only_future_events: true, something_else: '234')
47
+ def get_race race_id, **opts
48
+ # Response in format
49
+ # {
50
+ # "race": {
51
+ # "race_id": 33675,
52
+ # "name": "\"ASL Run Series: 5K Walk\/Run\" ASL Deaf",
53
+ # "last_date": "09\/29\/2018",
54
+ RunSignup::Race.new(call_api('/race', opts.merge(race_id: race_id))['race'])
55
+ end
56
+
57
+ protected
58
+
59
+ def call_api path, params = {}
60
+ response = self.class.get("#{BASE_URL}/#{path}", query: default_params.merge(params))
61
+ if response.code == 200
62
+ response = response.parsed_response
63
+
64
+ if (error = response['error'])
65
+ raise Error.new error['error_msg']
66
+ else
67
+ response
68
+ end
69
+ else
70
+ raise Error.new response.body
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,3 @@
1
+ module RunSignupApi
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: run_signup_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - dbwinger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dotenv
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: httparty
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Ruby wrapper for RunSignup.com API
56
+ email:
57
+ - daryl@entrision.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - Gemfile
63
+ - Gemfile.lock
64
+ - LICENSE.md
65
+ - README.md
66
+ - bin/console
67
+ - lib/run_signup/race.rb
68
+ - lib/run_signup_api.rb
69
+ - lib/run_signup_api/client.rb
70
+ - lib/run_signup_api/version.rb
71
+ homepage: https://github.com/dbwinger/run_signup_api
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubygems_version: 3.0.3
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Ruby wrapper for RunSignup.com API
94
+ test_files: []