toktokkie 0.0.1

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: 41c42b1d85b4238c87ffe412a4449728117471095f76f5e0da7587bced060ea2
4
+ data.tar.gz: 12bb44e3e55d15fff3e312083009c05cb98693f4778e8744af562da163325e84
5
+ SHA512:
6
+ metadata.gz: 715970dbfc859e4584ecf1a9f9731c247f2894a607a8560e1c0c6fcb09c75475b24c13fa7e405136619030326eeba512591eda505f25e293aed45f01326bbb2e
7
+ data.tar.gz: 69a6a729ab0af802ed04bfdd949f080164739a477b123dd8ce8aa8c5608243b4a6a919b97bdc49860c9937434c3d5cbfea4fa39846d223e11b4db1d03c47ec93
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,16 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Metrics/BlockLength
13
+ Enabled: false
14
+
15
+ Layout/LineLength:
16
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.0.1] - 2023-01-18
11
+
12
+ - Initial experimental release
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in toktokkie.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "rspec", "~> 3.0"
10
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ toktokkie (0.0.1)
5
+ faraday (~> 2.7.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ diff-lcs (1.5.0)
12
+ faraday (2.7.3)
13
+ faraday-net_http (>= 2.0, < 3.1)
14
+ ruby2_keywords (>= 0.0.4)
15
+ faraday-net_http (3.0.2)
16
+ json (2.6.3)
17
+ parallel (1.22.1)
18
+ parser (3.2.0.0)
19
+ ast (~> 2.4.1)
20
+ rainbow (3.1.1)
21
+ rake (13.0.6)
22
+ regexp_parser (2.6.1)
23
+ rexml (3.2.5)
24
+ rspec (3.12.0)
25
+ rspec-core (~> 3.12.0)
26
+ rspec-expectations (~> 3.12.0)
27
+ rspec-mocks (~> 3.12.0)
28
+ rspec-core (3.12.0)
29
+ rspec-support (~> 3.12.0)
30
+ rspec-expectations (3.12.2)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.12.0)
33
+ rspec-mocks (3.12.3)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.12.0)
36
+ rspec-support (3.12.0)
37
+ rubocop (1.43.0)
38
+ json (~> 2.3)
39
+ parallel (~> 1.10)
40
+ parser (>= 3.2.0.0)
41
+ rainbow (>= 2.2.2, < 4.0)
42
+ regexp_parser (>= 1.8, < 3.0)
43
+ rexml (>= 3.2.5, < 4.0)
44
+ rubocop-ast (>= 1.24.1, < 2.0)
45
+ ruby-progressbar (~> 1.7)
46
+ unicode-display_width (>= 2.4.0, < 3.0)
47
+ rubocop-ast (1.24.1)
48
+ parser (>= 3.1.1.0)
49
+ ruby-progressbar (1.11.0)
50
+ ruby2_keywords (0.0.5)
51
+ unicode-display_width (2.4.2)
52
+
53
+ PLATFORMS
54
+ arm64-darwin-22
55
+
56
+ DEPENDENCIES
57
+ rake (~> 13.0)
58
+ rspec (~> 3.0)
59
+ rubocop (~> 1.21)
60
+ toktokkie!
61
+
62
+ BUNDLED WITH
63
+ 2.4.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Christopher Spring
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,55 @@
1
+ # Toktokkie
2
+
3
+ ## Installation
4
+ Install the gem and add to the application's Gemfile by executing:
5
+
6
+ $ bundle add toktokkie_rb
7
+
8
+ If bundler is not being used to manage dependencies, install the gem by executing:
9
+
10
+ $ gem install toktokkie_rb
11
+
12
+ ## Configuration
13
+ ```ruby
14
+ Toktokkie.configure do |config|
15
+ config.key = "[YOUR_API_KEY]"
16
+ config.secret = "[YOUR_API_SECRET]"
17
+ end
18
+ ```
19
+
20
+ ## Usage
21
+ ```ruby
22
+ client = Toktokkie.client
23
+ client.create_event(
24
+ # required
25
+ payload: {
26
+ title: "New commenct",
27
+ body: "Charles commented on your blog post!",
28
+ action: {
29
+ "text": "View comment",
30
+ "url": "https://www.example.com/blog/1/comments#comment-2"
31
+ }
32
+ },
33
+ # required
34
+ recipients_payload: [
35
+ { external_id: "users-12345" }
36
+ ],
37
+ # optional
38
+ tags: ["Inbox A", "Inbox B"]
39
+ )
40
+ ```
41
+
42
+
43
+ ## Development
44
+
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
+
47
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/toktokkie.
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,37 @@
1
+ module Toktokkie
2
+ class Client
3
+ REQUEST_DEFAULTS = {
4
+ timeout: 10 # seconds
5
+ }
6
+
7
+ def initialize(key:, secret:, url:)
8
+ @key = key
9
+ @secret = secret
10
+ @url = url
11
+ end
12
+
13
+ def create_event(payload: {}, tags: [], recipients_payload: [])
14
+ response = connection.post("api/v1/events") do |request|
15
+ request.body = {
16
+ payload:,
17
+ tags:,
18
+ recipients_payload:
19
+ }.to_json
20
+ end
21
+ end
22
+
23
+ protected
24
+
25
+ def connection
26
+ @connection ||= Faraday.new(
27
+ url: @url,
28
+ request: REQUEST_DEFAULTS,
29
+ headers: {
30
+ "Content-Type" => "application/json",
31
+ "X-TOKTOK-KEY" => @key,
32
+ "X-TOKTOK-SECRET" => @secret,
33
+ },
34
+ )
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,24 @@
1
+ module Toktokkie
2
+ class Configuration
3
+ DEFAULT_URL = "https://www.toktokkie.io"
4
+
5
+ attr_accessor :key, :secret, :url
6
+
7
+ def initialize
8
+ self.url = DEFAULT_URL if blank?(url)
9
+ end
10
+
11
+ def usable?
12
+ %i[key secret url].none? do |setting|
13
+ puts "setting #{setting} #{send(setting)}"
14
+ blank?(send(setting))
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def blank?(var)
21
+ var.to_s.strip.length.zero?
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Toktokkie
4
+ VERSION = "0.0.1"
5
+ end
data/lib/toktokkie.rb ADDED
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+
5
+ require_relative "toktokkie/version"
6
+ require_relative "toktokkie/configuration"
7
+ require_relative "toktokkie/client"
8
+
9
+ module Toktokkie
10
+ ConfigurationError = Class.new(StandardError)
11
+
12
+ class << self
13
+ def configuration
14
+ @configuration ||= Toktokkie::Configuration.new
15
+ end
16
+
17
+ def reset_configuration
18
+ @configuration = nil
19
+ end
20
+
21
+ def client
22
+ @client ||= begin
23
+ raise ConfigurationError, "Missing configuration information" unless configuration.usable?
24
+ Toktokkie::Client.new(
25
+ key: configuration.key,
26
+ secret: configuration.secret,
27
+ url: configuration.url
28
+ )
29
+ end
30
+ end
31
+
32
+ def configure
33
+ yield configuration
34
+ end
35
+ end
36
+ end
data/sig/toktokkie.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Toktokkie
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
data/toktokkie.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/toktokkie/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "toktokkie"
7
+ spec.version = Toktokkie::VERSION
8
+ spec.authors = ["Christopher Spring"]
9
+ spec.email = ["chris@toktokkie.com"]
10
+
11
+ spec.summary = "Toktokkie ruby api client"
12
+ spec.description = "Interact with the Toktokkie api to create events and notifications"
13
+ spec.homepage = "https://github.com/TokTokkieOrg/toktokkie_rb"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/TokTokkieOrg/toktokkie_rb"
19
+ spec.metadata["changelog_uri"] = "https://github.com/TokTokkieOrg/toktokkie_rb/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
26
+ end
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ spec.add_dependency "faraday", "~> 2.7.3"
34
+
35
+ # For more information and examples about making a new gem, check out our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: toktokkie
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Spring
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-01-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.7.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.7.3
27
+ description: Interact with the Toktokkie api to create events and notifications
28
+ email:
29
+ - chris@toktokkie.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rspec"
35
+ - ".rubocop.yml"
36
+ - CHANGELOG.md
37
+ - Gemfile
38
+ - Gemfile.lock
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - lib/toktokkie.rb
43
+ - lib/toktokkie/client.rb
44
+ - lib/toktokkie/configuration.rb
45
+ - lib/toktokkie/version.rb
46
+ - sig/toktokkie.rbs
47
+ - toktokkie.gemspec
48
+ homepage: https://github.com/TokTokkieOrg/toktokkie_rb
49
+ licenses:
50
+ - MIT
51
+ metadata:
52
+ homepage_uri: https://github.com/TokTokkieOrg/toktokkie_rb
53
+ source_code_uri: https://github.com/TokTokkieOrg/toktokkie_rb
54
+ changelog_uri: https://github.com/TokTokkieOrg/toktokkie_rb/blob/main/CHANGELOG.md
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 2.6.0
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubygems_version: 3.4.1
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Toktokkie ruby api client
74
+ test_files: []