ruby-bofomatic 0.1.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
+ SHA256:
3
+ metadata.gz: e234add4c87404c069faec72d60419f44f7731487c9b3367b78b3cc5215264c4
4
+ data.tar.gz: 8080a16c869535807738e56384f2e9317656055800d95afdccb9c700856bcdb0
5
+ SHA512:
6
+ metadata.gz: 1d2a5ec45d90e0329746b92f76913761e90766066c20d0339e8568f6ab1768435fe00c80a159a7c1676959aac377b00ed2b847e85de8b5bc43952e40fea3169f
7
+ data.tar.gz: c6e79faa115125cab99512bb28f467e13e2c60629872b2a895d92d357ee55562d0fa0a5ca6ce884616b37fb2741347c2149cc6ca68bb44af3f0647119c742a64
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 sen
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # ruby-bofomatic
2
+ A Ruby gem to talk to the BoF-O-Matic system via its REST API
3
+
4
+ Documentation: coming soon! Once the API is a bit more firmed up.
@@ -0,0 +1,25 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+
4
+ module BofOMatic
5
+ class ApiV1
6
+ def initialize(url:, apikey:)
7
+ @url = url
8
+ @apikey = apikey
9
+ end
10
+
11
+ def api_get(path_fragment)
12
+ response = RestClient.get "#{@url}/api/v1/#{path_fragment}", { Authorization: "Bearer #{@apikey}" }
13
+ # TODO: error handling
14
+ JSON.parse(response)
15
+ end
16
+
17
+ def api_post(path_fragment, data)
18
+ response = RestClient.post "#{@url}/api/v1/#{path_fragment}", data.to_json, { Authorization: "Bearer #{@apikey}", :content_type => 'application/json' }
19
+ end
20
+
21
+ def proposals
22
+ Proposals.new(self)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,91 @@
1
+ module BofOMatic
2
+ class GenericCollection
3
+ include Enumerable
4
+
5
+ def [](id)
6
+ @data[id]
7
+ end
8
+
9
+ def each
10
+ @data.each do |id, datum|
11
+ yield datum
12
+ end
13
+ end
14
+
15
+ def is_empty?
16
+ @data == {}
17
+ end
18
+ end
19
+
20
+ class GenericData
21
+ def method_missing(key)
22
+ super unless @data.include? key.to_s
23
+ if(key.end_with? '_at' or key.end_with? '_time') then
24
+ Time.new(@data[key.to_s])
25
+ else
26
+ @data[key.to_s]
27
+ end
28
+ end
29
+ end
30
+
31
+ class Proposals < GenericCollection
32
+ def initialize(api)
33
+ @api = api
34
+
35
+ response = @api.api_get("proposals")
36
+
37
+ @data = {}
38
+ response.each do |id, proposal_hash|
39
+ @data[id.to_i] = Proposal.new(@api, proposal_hash)
40
+ end
41
+ end
42
+
43
+ def new(submitted_by:, submitter_email:, submitter_phone: nil, session_title:, session_description:, scheduler_notes: nil)
44
+ @api.api_post("proposals/new", {
45
+ submitted_by: submitted_by,
46
+ submitter_email: submitter_email,
47
+ submitter_phone: submitter_phone,
48
+ session_title: session_title,
49
+ session_description: session_description,
50
+ scheduler_notes: scheduler_notes
51
+ })
52
+ end
53
+ end
54
+
55
+ class Proposal < GenericData
56
+ def initialize(api, proposal_hash)
57
+ @api = api
58
+ @data = proposal_hash
59
+ end
60
+
61
+ def interests
62
+ Interests.new @api, self
63
+ end
64
+
65
+ def add_interest(name:, email: nil, phone: nil)
66
+ @api.api_post("proposals/#{self.id}/interests", {name: name, email: email, phone: phone})
67
+ end
68
+ end
69
+
70
+ class Interests < GenericCollection
71
+ def initialize(api, proposal)
72
+ @api = api
73
+ @proposal = proposal
74
+
75
+ response = @api.api_get("proposals/#{proposal.id}/interests")
76
+
77
+ @data = {}
78
+ response.each do |id, interest_hash|
79
+ @data[id.to_i] = Interest.new(self, proposal, interest_hash)
80
+ end
81
+ end
82
+ end
83
+
84
+ class Interest < GenericData
85
+ def initialize(api, proposal, interest_hash)
86
+ @api = api
87
+ @proposal = proposal
88
+ @data = interest_hash
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,3 @@
1
+ module BofOMatic
2
+ VERSION="0.1.0"
3
+ end
data/lib/bofomatic.rb ADDED
@@ -0,0 +1,3 @@
1
+ require_relative 'bofomatic/version'
2
+ require_relative 'bofomatic/api'
3
+ require_relative 'bofomatic/data'
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-bofomatic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - sen
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rest-client
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: 2.0.0
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: 2.0.0
26
+ description: Gem for reading and writing data from BoF-O-Matic using the REST API.
27
+ email:
28
+ - rubygems@sen.cx
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - LICENSE
34
+ - README.md
35
+ - lib/bofomatic.rb
36
+ - lib/bofomatic/api.rb
37
+ - lib/bofomatic/data.rb
38
+ - lib/bofomatic/version.rb
39
+ homepage: http://github.com/sarahemm/ruby-bofomatic
40
+ licenses:
41
+ - MIT
42
+ metadata: {}
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 3.0.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 1.3.6
56
+ requirements: []
57
+ rubygems_version: 4.0.21
58
+ specification_version: 4
59
+ summary: BoF-O-Matic API gem
60
+ test_files: []