Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact list feature #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,28 @@ AllCops:
Exclude:
- 'gemfiles/**/*'
- '**/*.json'
- bin/**/*

RSpec/MultipleMemoizedHelpers:
Enabled: false

Lint/MissingSuper:
Exclude:
- 'lib/active_campaign.rb'
- 'lib/active_campaign/*'

Naming/VariableNumber:
Exclude:
- 'spec/**/*'

Layout/ExtraSpacing:
Exclude:
- 'spec/support/shared_contexts/*'

Lint/EmptyBlock:
Exclude:
- 'spec/support/shared_contexts/*'

RSpec/AlignLeftLetBrace:
Exclude:
- 'spec/support/shared_contexts/*'
2 changes: 2 additions & 0 deletions active_campaign.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Gem::Specification.new do |spec|
'public gem pushes.'
end

spec.required_ruby_version = '>= 2.5.0'

spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
# spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
Expand Down
2 changes: 1 addition & 1 deletion lib/active_campaign/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def endpoint(endpoint)
# @return [Logger] any object that responds to :debug, :info, :warn, :error and :fatal
#
def logger
@logger ||= ActiveCampaign.logger
@logger ||= ActiveCampaign.logger # rubocop:disable ThreadSafety/InstanceVariableInClassMethod - should be a fixme
end
end
end
Expand Down
26 changes: 26 additions & 0 deletions lib/active_campaign/api/contact_lists.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

module ActiveCampaign
module API
#
# Interface to contact list endpoints
#
# @author Daniel Moreira <[email protected]>
#
module ContactLists
#
# Subscribe a contact to a list or unsubscribe a contact from a list
#
# @param [Hash] params add a contact to a list with this data
# @param params [String] :contact ID of the contact you're adding the tag to
# @param params [String] :list ID of the list to subscribe the contact to
# @param params [String] :status Set to "1" to subscribe or "2" to unsubscribe.
#
# @return [Hash] a hash with the information of the newly created contact list
#
def update_contact_list(params)
post('contactLists', contact_list: params)
end
end
end
end
5 changes: 1 addition & 4 deletions lib/active_campaign/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Client
endpoint :accounts
endpoint :addresses
endpoint :contacts
endpoint :contact_lists
endpoint :contact_tags
endpoint :deals
endpoint :deal_custom_field_meta
Expand Down Expand Up @@ -100,8 +101,6 @@ def safe_http_call # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
raise ProxyAuthError, e
rescue ::Faraday::ConflictError => e
raise ConflictError, e
rescue ::Faraday::UnauthorizedError => e
raise UnauthorizedError, e
rescue ::Faraday::UnprocessableEntityError => e
raise UnprocessableEntityError, e
rescue ::Faraday::ServerError => e
Expand All @@ -110,8 +109,6 @@ def safe_http_call # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
raise TimeoutError, e
rescue ::Faraday::NilStatusError => e
raise NilStatusError, e
rescue ::Faraday::ConnectionFailed => e
raise ConnectionFailed, e
rescue ::Faraday::SSLError => e
raise SSLError, e
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_campaign/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def initialize
self.api_timeout = 5
self.api_token = API_TOKEN
self.debug = false
self.logger = Logger.new(STDOUT)
self.logger = Logger.new($stdout)
@request_middleware = {}
@response_middleware = {}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_campaign/faraday/middleware/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def normalize_body(env)
end

def logger
@logger ||= Logger.new(STDOUT)
@logger ||= Logger.new($stdout)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_campaign/faraday/middleware/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'faraday/logging/formatter'

module ActiveCampaign
LOGGER = ::Logger.new(STDOUT)
LOGGER = ::Logger.new($stdout)
module Faraday
module Middleware
#
Expand Down
Loading