Skip to content

Commit

Permalink
Chore: Add account activity subscription actions (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
sojan-official authored May 13, 2020
1 parent af4f3e4 commit 953a61e
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 27 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ references:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
jobs:
"ruby-2.6":
"ruby-2.7":
docker:
- image: circleci/ruby:2.6
- image: circleci/ruby:2.7
steps:
- checkout
- <<: *restore
Expand All @@ -35,4 +35,4 @@ workflows:
version: 2
build:
jobs:
- "ruby-2.6"
- "ruby-2.7"
42 changes: 42 additions & 0 deletions .github/workflows/gempush.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Ruby Gem

on:
push:
branches: [ master ]

jobs:
build:
name: Build + Publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.7
uses: actions/setup-ruby@v1
with:
version: 2.7.1

- name: Publish to RubyGems
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${{ env.GEM_HOST_API_KEY }}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push *.gem
continue-on-error: true
env:
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}

- name: Publish to GPR
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:github: Bearer ${{ env.GEM_HOST_API_KEY }}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push --KEY github --host https://rubygems.pkg.github.com/${{ env.OWNER }} *.gem
continue-on-error: true
env:
GEM_HOST_API_KEY: ${{secrets.GPR_AUTH_TOKEN}}
OWNER: chatwoot
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

# rspec failure tracking
.rspec_status
*.gem
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.1
26 changes: 13 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ GEM
diff-lcs (1.3)
oauth (0.5.4)
rake (13.0.1)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)

PLATFORMS
ruby

DEPENDENCIES
bundler (~> 1.17)
bundler (~> 2)
oauth
rake (~> 13.0)
rspec (~> 3.0)
twitty!

BUNDLED WITH
1.17.3
2.1.4
22 changes: 17 additions & 5 deletions lib/twitty/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,31 @@ module Constants
endpoint: '/1.1/account_activity/all/%{env}/webhooks.json?url=%{url}',
required_params: [:url]
},

unregister_webhook: {
method: :delete,
endpoint: '/1.1/account_activity/all/%{env}/webhooks/%{id}.json',
required_params: [:id]
},

fetch_subscriptions: {
method: :get,
endpoint: '/1.1/account_activity/all/%{env}/subscriptions.json',
required_params: []
},

subscribe_webhook: {
create_subscription: {
method: :post,
endpoint: '/1.1/account_activity/all/%{env}/subscriptions.json',
required_params: []
},

unsubscribe_webhook: {
remove_subscription: {
method: :delete,
endpoint: '/1.1/account_activity/all/%{env}/webhooks/%{id}.json',
required_params: [:id]
endpoint: '/1.1/account_activity/all/%{env}/subscriptions/%{user_id}.json',
required_params: [:user_id]
},

send_direct_message: {
method: :post,
endpoint: '/1.1/direct_messages/events/new.json',
Expand Down
2 changes: 1 addition & 1 deletion lib/twitty/payload.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Twitty
module Payload
EMPTY_PAYLOAD_ACTIONS = %w[fetch_webhooks register_webhook subscribe_webhook unsubscribe_webhook].freeze
EMPTY_PAYLOAD_ACTIONS = %w[fetch_webhooks register_webhook unregister_webhook fetch_subscriptions create_subscription remove_subscription].freeze

EMPTY_PAYLOAD_ACTIONS.each do |action|
define_method "#{action.to_s}_payload" do
Expand Down
2 changes: 1 addition & 1 deletion lib/twitty/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Twitty
VERSION = "0.1.0"
VERSION = "0.1.1"
end
14 changes: 10 additions & 4 deletions twitty.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ require "twitty/version"
Gem::Specification.new do |spec|
spec.name = "twitty"
spec.version = Twitty::VERSION
spec.authors = ["Subin T P"]
spec.email = ["[email protected]"]
spec.authors = ["Subin T P", "Pranav Raj S", "Sojan Jose"]
spec.email = ["[email protected]","subin@thoughtwoot.com", "[email protected]", "sojan@thoughtwoot.com"]

spec.summary = %q{Twitter API wrapper}
spec.description = %q{Twitter API wrapper}
spec.description = %q{Twitty makes working with the twitter account subscriptions APIs much easier}
spec.homepage = "https://www.chatwoot.com"
spec.license = "MIT"

spec.metadata = {
"bug_tracker_uri" => "https://github.com/chatwoot/twitty/issues",
"homepage_uri" => "https://github.com/chatwoot/twitty",
"source_code_uri" => "https://github.com/chatwoot/twitty",
}

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
Expand All @@ -23,7 +29,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 1.17"
spec.add_development_dependency "bundler", "~> 2"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_runtime_dependency "oauth"
Expand Down

0 comments on commit 953a61e

Please sign in to comment.