runreg_api 0.0.2

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: e0dd99817a68ce527b4a36f398ccec7463cfa491815998c111f5e4af263f13cf
4
+ data.tar.gz: 7160b63515108f8ed5d8397a6bd2fd51ff40ee706676d7112fa13eed12ae5d0d
5
+ SHA512:
6
+ metadata.gz: 4f5ffb5a0699682d0f29f1a855bbdc9858d5cc7d0929bd7d0360ecca6569b4041113e807fd84c44ce5f5a33b2261162fd6d73562be7241a9d2882d647fc6ba89
7
+ data.tar.gz: 8c3acdfd9aa834f95dd5c9fc94e22bb812ca3fc4861de8ae49862848c2dcf34b7c8da8774524fed41481f1a05dbc6527889360b590a059966dab1f3f5d5e87aa
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,44 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ runreg_api (0.0.1)
5
+ httparty
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ byebug (11.1.1)
11
+ diff-lcs (1.3)
12
+ dotenv (2.7.5)
13
+ httparty (0.17.3)
14
+ mime-types (~> 3.0)
15
+ multi_xml (>= 0.5.2)
16
+ mime-types (3.3.1)
17
+ mime-types-data (~> 3.2015)
18
+ mime-types-data (3.2019.1009)
19
+ multi_xml (0.6.0)
20
+ rspec (3.9.0)
21
+ rspec-core (~> 3.9.0)
22
+ rspec-expectations (~> 3.9.0)
23
+ rspec-mocks (~> 3.9.0)
24
+ rspec-core (3.9.1)
25
+ rspec-support (~> 3.9.1)
26
+ rspec-expectations (3.9.0)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.9.0)
29
+ rspec-mocks (3.9.1)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.9.0)
32
+ rspec-support (3.9.2)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ byebug
39
+ dotenv
40
+ rspec
41
+ runreg_api!
42
+
43
+ BUNDLED WITH
44
+ 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/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "runreg_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,17 @@
1
+ require 'ostruct'
2
+
3
+ module Runreg
4
+ class Event < OpenStruct
5
+ def initialize hash
6
+ %w(EventDate EventEndDate).each do |key|
7
+ hash[key] = convert_datetime(hash[key]) if hash[key] if hash['EventDate']
8
+ end
9
+
10
+ super
11
+ end
12
+
13
+ def convert_datetime string
14
+ DateTime.strptime(string, '/Date(%Q%z)/').to_s
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,35 @@
1
+ require 'httparty'
2
+
3
+ module RunregApi
4
+ class Client
5
+ include HTTParty
6
+
7
+ BASE_URL = "https://www.runreg.com/api"
8
+
9
+ def search **opts
10
+ # Response in format
11
+ # {
12
+ # "CompletionTime":0,
13
+ # "MatchingEvents":[
14
+ # {
15
+ # "Categories":[
16
+ # {
17
+ # "CategoryID":34293
18
+ # ...
19
+ call_api('search', opts)['MatchingEvents'].map do |event|
20
+ Runreg::Event.new(event)
21
+ end
22
+ end
23
+
24
+ protected
25
+
26
+ def call_api path, params = {}
27
+ response = self.class.get("#{BASE_URL}/#{path}", query: params)
28
+ if response.code == 200
29
+ response.parsed_response
30
+ else
31
+ raise Error.new response.body
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module RunregApi
2
+ VERSION = '0.0.2'
3
+ end
data/lib/runreg_api.rb ADDED
@@ -0,0 +1,12 @@
1
+ if ENV['ENV'] == 'development'
2
+ require 'dotenv/load'
3
+ require 'byebug'
4
+ end
5
+ require 'runreg_api/version'
6
+ require 'runreg/event'
7
+ require 'runreg_api/client'
8
+
9
+
10
+ module RunregApi
11
+ class Error < StandardError; end;
12
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: runreg_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - dbwinger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-01 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: '0'
20
+ type: :development
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: byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: dotenv
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: "[description]"
70
+ email:
71
+ - daryl@entrision.com
72
+ executables:
73
+ - console
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - LICENSE.md
80
+ - bin/console
81
+ - lib/runreg/event.rb
82
+ - lib/runreg_api.rb
83
+ - lib/runreg_api/client.rb
84
+ - lib/runreg_api/version.rb
85
+ homepage: https://github.com/dbwinger/runreg_api
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubygems_version: 3.0.3
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: "[summary]"
108
+ test_files: []