action_kit_rest 0.4.4 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +24 -0
- data/.rubocop.yml +26 -0
- data/.ruby-version +1 -1
- data/Gemfile +11 -9
- data/README.md +2 -2
- data/Rakefile +15 -18
- data/action_kit_rest.gemspec +28 -34
- data/lib/action_kit_rest/action.rb +3 -1
- data/lib/action_kit_rest/actions/event_create_action.rb +5 -3
- data/lib/action_kit_rest/actions/event_signup_action.rb +6 -3
- data/lib/action_kit_rest/actions/unsubscribe_action.rb +3 -1
- data/lib/action_kit_rest/allowed_user_field.rb +3 -1
- data/lib/action_kit_rest/api.rb +9 -7
- data/lib/action_kit_rest/base.rb +5 -4
- data/lib/action_kit_rest/client.rb +5 -3
- data/lib/action_kit_rest/event.rb +3 -1
- data/lib/action_kit_rest/event_signup.rb +3 -1
- data/lib/action_kit_rest/language.rb +3 -1
- data/lib/action_kit_rest/list.rb +3 -1
- data/lib/action_kit_rest/page.rb +4 -2
- data/lib/action_kit_rest/pages/base.rb +4 -5
- data/lib/action_kit_rest/pages/donation_page.rb +3 -1
- data/lib/action_kit_rest/pages/event_campaign_page.rb +4 -2
- data/lib/action_kit_rest/pages/import_page.rb +3 -1
- data/lib/action_kit_rest/pages/signup_page.rb +3 -1
- data/lib/action_kit_rest/pages/unsubscribe_page.rb +3 -1
- data/lib/action_kit_rest/phone.rb +2 -0
- data/lib/action_kit_rest/railties.rb +3 -1
- data/lib/action_kit_rest/response/collection.rb +4 -4
- data/lib/action_kit_rest/response/raise_error.rb +15 -12
- data/lib/action_kit_rest/response/validation_error.rb +20 -9
- data/lib/action_kit_rest/response/wrapper.rb +10 -10
- data/lib/action_kit_rest/tag.rb +6 -6
- data/lib/action_kit_rest/user.rb +3 -1
- data/lib/action_kit_rest/version.rb +3 -1
- data/lib/action_kit_rest.rb +2 -0
- data/spec/lib/action_kit_rest/actions/event_create_action_spec.rb +6 -4
- data/spec/lib/action_kit_rest/actions/event_signup_action_spec.rb +6 -4
- data/spec/lib/action_kit_rest/allowed_user_field_spec.rb +9 -7
- data/spec/lib/action_kit_rest/api_spec.rb +103 -0
- data/spec/lib/action_kit_rest/logger_spec.rb +7 -5
- data/spec/lib/action_kit_rest/page_spec.rb +28 -28
- data/spec/lib/action_kit_rest/pages/event_campaign_page_spec.rb +25 -20
- data/spec/lib/action_kit_rest/pages/import_page_spec.rb +21 -17
- data/spec/lib/action_kit_rest/response/collection_spec.rb +13 -11
- data/spec/lib/action_kit_rest/response/validation_error_spec.rb +16 -4
- data/spec/lib/action_kit_rest/response/wrapper_spec.rb +6 -4
- data/spec/lib/action_kit_rest/user_spec.rb +11 -9
- data/spec/spec_helper.rb +6 -4
- data/spec/support/shared_contexts/stub_logger.rb +4 -2
- metadata +64 -54
- data/.travis.yml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48de2f5ea6be39c19b8d17dcf608e48fb34667be18ccb03d725f5c31e9f70ccf
|
4
|
+
data.tar.gz: cbb7ff2006d5156b254a903d2f1594aac5399fdc32830cf55fb1719913a00b62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9743a40e310c262790a11f011ef1c9d3c8bfe0a05df0633894200b1e8330aa990e7b57aebac1dac0d3ce455e0ddd14a3b57ff4f5a82e5a357b61be9e51b4c65b
|
7
|
+
data.tar.gz: f6764a07deca62c39b3005aecadfc2cc0c8276c6e68bf1294960376155e3bb3773a4e18e079afa0b561435c7f7b8bd8c5e0c98b63246362ffd2c56a916513eaf
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: CI
|
2
|
+
on: [push]
|
3
|
+
|
4
|
+
jobs:
|
5
|
+
test:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
steps:
|
8
|
+
- uses: actions/checkout@v2
|
9
|
+
- uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
|
10
|
+
with:
|
11
|
+
ruby-version: 2.7
|
12
|
+
bundler-cache: true
|
13
|
+
- run: bundle install
|
14
|
+
- run: bundle exec rspec
|
15
|
+
rubocop:
|
16
|
+
runs-on: ubuntu-latest
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
- uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
|
20
|
+
with:
|
21
|
+
ruby-version: 2.7
|
22
|
+
bundler-cache: true
|
23
|
+
- run: bundle install
|
24
|
+
- run: bundle exec rubocop
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisabledByDefault: true
|
3
|
+
|
4
|
+
Security:
|
5
|
+
Enabled: true
|
6
|
+
|
7
|
+
Bundler/DuplicatedGem:
|
8
|
+
Enabled: true
|
9
|
+
Bundler/InsecureProtocolSource:
|
10
|
+
Enabled: true
|
11
|
+
Layout/IndentationStyle:
|
12
|
+
Enabled: true
|
13
|
+
Layout/SpaceInsideRangeLiteral:
|
14
|
+
Enabled: true
|
15
|
+
Lint:
|
16
|
+
Enabled: true
|
17
|
+
Lint/RaiseException:
|
18
|
+
Enabled: true
|
19
|
+
Naming/AsciiIdentifiers:
|
20
|
+
Enabled: true
|
21
|
+
Naming/ClassAndModuleCamelCase:
|
22
|
+
Enabled: true
|
23
|
+
Naming/ConstantName:
|
24
|
+
Enabled: true
|
25
|
+
Naming/FileName:
|
26
|
+
Enabled: true
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.4
|
data/Gemfile
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source 'http://rubygems.org'
|
4
|
+
|
5
|
+
gem 'vertebrae', '>= 0.6.0'
|
4
6
|
|
5
7
|
group :development do
|
6
|
-
gem 'rspec', '~> 3.7'
|
7
|
-
gem 'webmock', '~> 3.3'
|
8
|
-
gem 'byebug'
|
9
8
|
gem 'bundler', '>= 2.0', '<3.0'
|
10
|
-
gem '
|
11
|
-
gem 'em-synchrony', '>=1.0.6', '<2.0'
|
9
|
+
gem 'byebug'
|
12
10
|
gem 'em-http-request', '>=1.1.5', '<2.0'
|
13
|
-
gem '
|
11
|
+
gem 'em-synchrony', '>=1.0.6', '<2.0'
|
12
|
+
gem 'eventmachine', '>=1.2.5', '<2.0'
|
13
|
+
gem 'juwelier', git: 'https://github.com/flajann2/juwelier.git'
|
14
|
+
gem 'rspec', '~> 3.7'
|
15
|
+
gem 'rubocop'
|
16
|
+
gem 'webmock', '~> 3.3'
|
14
17
|
end
|
15
|
-
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# action\_kit\_rest
|
2
2
|
|
3
3
|
A ruby binding for the ActionKit REST API
|
4
4
|
|
5
|
-
[![
|
5
|
+
[![CI Status](https://github.com/controlshift/action_kit_rest/actions/workflows/ci.yml/badge.svg)](https://github.com/controlshift/action_kit_rest/actions/workflows/ci.yml)
|
6
6
|
|
7
7
|
## Usage
|
8
8
|
|
data/Rakefile
CHANGED
@@ -1,47 +1,44 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'bundler'
|
5
5
|
begin
|
6
6
|
Bundler.setup(:default, :development)
|
7
7
|
rescue Bundler::BundlerError => e
|
8
|
-
|
9
|
-
|
8
|
+
warn e.message
|
9
|
+
warn 'Run `bundle install` to install missing gems'
|
10
10
|
exit e.status_code
|
11
11
|
end
|
12
12
|
require 'rake'
|
13
|
-
require './lib/action_kit_rest/version
|
14
|
-
|
13
|
+
require './lib/action_kit_rest/version'
|
15
14
|
|
16
15
|
require 'juwelier'
|
17
16
|
Juwelier::Tasks.new do |gem|
|
18
|
-
|
19
|
-
gem.name = "action_kit_rest"
|
17
|
+
gem.name = 'action_kit_rest'
|
20
18
|
gem.version = ActionKitRest::VERSION::STRING
|
21
|
-
gem.homepage =
|
22
|
-
gem.license =
|
23
|
-
gem.summary = %
|
24
|
-
gem.description = %
|
25
|
-
gem.email =
|
26
|
-
gem.authors = [
|
19
|
+
gem.homepage = 'http://github.com/controlshift/action_kit_rest'
|
20
|
+
gem.license = 'MIT'
|
21
|
+
gem.summary = %(A wrapper for the ActionKit REST API)
|
22
|
+
gem.description = %(Gem for interacting with the ActionKit API)
|
23
|
+
gem.email = 'systems@controlshiftlabs.com'
|
24
|
+
gem.authors = ['Nathan Woodhull', 'Diego Marcet', 'Grey Moore']
|
27
25
|
# dependencies defined in Gemfile
|
28
26
|
end
|
29
27
|
Juwelier::RubygemsDotOrgTasks.new
|
30
28
|
|
31
|
-
|
32
29
|
require 'rspec/core/rake_task'
|
33
30
|
desc 'Default: run specs.'
|
34
|
-
task :
|
31
|
+
task default: :spec
|
35
32
|
|
36
|
-
desc
|
33
|
+
desc 'Run specs'
|
37
34
|
RSpec::Core::RakeTask.new do |t|
|
38
|
-
t.pattern =
|
35
|
+
t.pattern = './spec/**/*_spec.rb' # don't need this, it's default.
|
39
36
|
t.rspec_opts = '--color'
|
40
37
|
end
|
41
38
|
|
42
39
|
require 'rdoc/task'
|
43
40
|
Rake::RDocTask.new do |rdoc|
|
44
|
-
version = File.exist?('VERSION') ? File.read('VERSION') :
|
41
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ''
|
45
42
|
|
46
43
|
rdoc.rdoc_dir = 'rdoc'
|
47
44
|
rdoc.title = "action_kit_rest #{version}"
|
data/action_kit_rest.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: action_kit_rest 0.4.
|
5
|
+
# stub: action_kit_rest 0.4.8 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "action_kit_rest".freeze
|
9
|
-
s.version = "0.4.
|
9
|
+
s.version = "0.4.8"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
|
-
s.authors = ["Nathan Woodhull".freeze, "Diego Marcet".freeze, "
|
14
|
-
s.date = "
|
13
|
+
s.authors = ["Nathan Woodhull".freeze, "Diego Marcet".freeze, "Grey Moore".freeze]
|
14
|
+
s.date = "2021-10-07"
|
15
15
|
s.description = "Gem for interacting with the ActionKit API".freeze
|
16
16
|
s.email = "systems@controlshiftlabs.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -20,10 +20,11 @@ Gem::Specification.new do |s|
|
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
|
+
".github/workflows/ci.yml",
|
23
24
|
".rspec",
|
25
|
+
".rubocop.yml",
|
24
26
|
".ruby-gemset",
|
25
27
|
".ruby-version",
|
26
|
-
".travis.yml",
|
27
28
|
"Gemfile",
|
28
29
|
"LICENSE.txt",
|
29
30
|
"README.md",
|
@@ -76,6 +77,7 @@ Gem::Specification.new do |s|
|
|
76
77
|
"spec/lib/action_kit_rest/actions/event_create_action_spec.rb",
|
77
78
|
"spec/lib/action_kit_rest/actions/event_signup_action_spec.rb",
|
78
79
|
"spec/lib/action_kit_rest/allowed_user_field_spec.rb",
|
80
|
+
"spec/lib/action_kit_rest/api_spec.rb",
|
79
81
|
"spec/lib/action_kit_rest/logger_spec.rb",
|
80
82
|
"spec/lib/action_kit_rest/page_spec.rb",
|
81
83
|
"spec/lib/action_kit_rest/pages/event_campaign_page_spec.rb",
|
@@ -89,43 +91,35 @@ Gem::Specification.new do |s|
|
|
89
91
|
]
|
90
92
|
s.homepage = "http://github.com/controlshift/action_kit_rest".freeze
|
91
93
|
s.licenses = ["MIT".freeze]
|
92
|
-
s.rubygems_version = "3.
|
94
|
+
s.rubygems_version = "3.1.6".freeze
|
93
95
|
s.summary = "A wrapper for the ActionKit REST API".freeze
|
94
96
|
|
95
97
|
if s.respond_to? :specification_version then
|
96
98
|
s.specification_version = 4
|
99
|
+
end
|
97
100
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
s.add_dependency(%q<vertebrae>.freeze, ["> 0.5.0"])
|
110
|
-
s.add_dependency(%q<rspec>.freeze, ["~> 3.7"])
|
111
|
-
s.add_dependency(%q<webmock>.freeze, ["~> 3.3"])
|
112
|
-
s.add_dependency(%q<byebug>.freeze, [">= 0"])
|
113
|
-
s.add_dependency(%q<bundler>.freeze, [">= 2.0", "< 3.0"])
|
114
|
-
s.add_dependency(%q<eventmachine>.freeze, [">= 1.2.5", "< 2.0"])
|
115
|
-
s.add_dependency(%q<em-synchrony>.freeze, [">= 1.0.6", "< 2.0"])
|
116
|
-
s.add_dependency(%q<em-http-request>.freeze, [">= 1.1.5", "< 2.0"])
|
117
|
-
s.add_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0"])
|
118
|
-
end
|
101
|
+
if s.respond_to? :add_runtime_dependency then
|
102
|
+
s.add_runtime_dependency(%q<vertebrae>.freeze, [">= 0.6.0"])
|
103
|
+
s.add_development_dependency(%q<bundler>.freeze, [">= 2.0", "< 3.0"])
|
104
|
+
s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
|
105
|
+
s.add_development_dependency(%q<em-http-request>.freeze, [">= 1.1.5", "< 2.0"])
|
106
|
+
s.add_development_dependency(%q<em-synchrony>.freeze, [">= 1.0.6", "< 2.0"])
|
107
|
+
s.add_development_dependency(%q<eventmachine>.freeze, [">= 1.2.5", "< 2.0"])
|
108
|
+
s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
|
109
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.7"])
|
110
|
+
s.add_development_dependency(%q<rubocop>.freeze, [">= 0"])
|
111
|
+
s.add_development_dependency(%q<webmock>.freeze, ["~> 3.3"])
|
119
112
|
else
|
120
|
-
s.add_dependency(%q<vertebrae>.freeze, ["
|
121
|
-
s.add_dependency(%q<rspec>.freeze, ["~> 3.7"])
|
122
|
-
s.add_dependency(%q<webmock>.freeze, ["~> 3.3"])
|
123
|
-
s.add_dependency(%q<byebug>.freeze, [">= 0"])
|
113
|
+
s.add_dependency(%q<vertebrae>.freeze, [">= 0.6.0"])
|
124
114
|
s.add_dependency(%q<bundler>.freeze, [">= 2.0", "< 3.0"])
|
125
|
-
s.add_dependency(%q<
|
126
|
-
s.add_dependency(%q<em-synchrony>.freeze, [">= 1.0.6", "< 2.0"])
|
115
|
+
s.add_dependency(%q<byebug>.freeze, [">= 0"])
|
127
116
|
s.add_dependency(%q<em-http-request>.freeze, [">= 1.1.5", "< 2.0"])
|
128
|
-
s.add_dependency(%q<
|
117
|
+
s.add_dependency(%q<em-synchrony>.freeze, [">= 1.0.6", "< 2.0"])
|
118
|
+
s.add_dependency(%q<eventmachine>.freeze, [">= 1.2.5", "< 2.0"])
|
119
|
+
s.add_dependency(%q<juwelier>.freeze, [">= 0"])
|
120
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.7"])
|
121
|
+
s.add_dependency(%q<rubocop>.freeze, [">= 0"])
|
122
|
+
s.add_dependency(%q<webmock>.freeze, ["~> 3.3"])
|
129
123
|
end
|
130
124
|
end
|
131
125
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionKitRest
|
2
4
|
module Actions
|
3
5
|
class EventCreateAction < Action
|
@@ -9,11 +11,11 @@ module ActionKitRest
|
|
9
11
|
ak_event_create_action = super
|
10
12
|
|
11
13
|
# Aggregate fields parsed from referrenced entities' URI
|
12
|
-
ak_event_create_action.obj['event_id'] = ak_event_create_action.event.match(
|
13
|
-
ak_event_create_action.obj['user_id'] = ak_event_create_action.user.match(
|
14
|
+
ak_event_create_action.obj['event_id'] = ak_event_create_action.event.match(%r{/rest/v1/event/(\d*)/})[1]
|
15
|
+
ak_event_create_action.obj['user_id'] = ak_event_create_action.user.match(%r{/rest/v1/user/(\d*)/})[1]
|
14
16
|
|
15
17
|
ak_event_create_action
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
19
|
-
end
|
21
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionKitRest
|
2
4
|
module Actions
|
3
5
|
class EventSignupAction < Action
|
@@ -9,11 +11,12 @@ module ActionKitRest
|
|
9
11
|
ak_event_signup_action = super
|
10
12
|
|
11
13
|
# Aggregate fields parsed from referrenced entities' URI
|
12
|
-
ak_event_signup_action.obj['event_signup_id'] =
|
13
|
-
|
14
|
+
ak_event_signup_action.obj['event_signup_id'] =
|
15
|
+
ak_event_signup_action.signup.match(%r{/rest/v1/eventsignup/(\d*)/})[1]
|
16
|
+
ak_event_signup_action.obj['user_id'] = ak_event_signup_action.user.match(%r{/rest/v1/user/(\d*)/})[1]
|
14
17
|
|
15
18
|
ak_event_signup_action
|
16
19
|
end
|
17
20
|
end
|
18
21
|
end
|
19
|
-
end
|
22
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionKitRest
|
2
4
|
class AllowedUserField < Base
|
3
5
|
def base_path
|
@@ -14,7 +16,7 @@ module ActionKitRest
|
|
14
16
|
# We must override this, because the paths for allowed user fields use the name,
|
15
17
|
# not a numerical ID.
|
16
18
|
def extract_id_from_response(resp)
|
17
|
-
resp.response.headers[
|
19
|
+
resp.response.headers['location'].split('/').last
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
data/lib/action_kit_rest/api.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionKitRest
|
2
4
|
class API < Vertebrae::API
|
3
|
-
|
4
5
|
def request(*args)
|
5
|
-
ActionKitRest::Response::Wrapper.new(
|
6
|
+
ActionKitRest::Response::Wrapper.new(super(*args))
|
6
7
|
end
|
7
8
|
|
8
9
|
def post_json_request(path, params)
|
@@ -18,10 +19,10 @@ module ActionKitRest
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def extract_data_from_params(params) # :nodoc:
|
21
|
-
if params.
|
22
|
-
|
22
|
+
if params.key?('data') && params['data'].present?
|
23
|
+
params['data']
|
23
24
|
else
|
24
|
-
|
25
|
+
params
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
@@ -38,7 +39,8 @@ module ActionKitRest
|
|
38
39
|
builder.use Faraday::Request::Multipart
|
39
40
|
builder.use Faraday::Request::UrlEncoded
|
40
41
|
if connection.configuration.authenticated?
|
41
|
-
builder.use Faraday::Request::BasicAuthentication, connection.configuration.username,
|
42
|
+
builder.use Faraday::Request::BasicAuthentication, connection.configuration.username,
|
43
|
+
connection.configuration.password
|
42
44
|
end
|
43
45
|
|
44
46
|
builder.use Faraday::Response::Logger if ENV['DEBUG']
|
@@ -46,7 +48,7 @@ module ActionKitRest
|
|
46
48
|
builder.use FaradayMiddleware::Mashify
|
47
49
|
builder.use FaradayMiddleware::ParseJson
|
48
50
|
|
49
|
-
builder.use
|
51
|
+
builder.use ActionKitRest::Response::RaiseError
|
50
52
|
builder.adapter connection.configuration.adapter
|
51
53
|
end
|
52
54
|
end
|
data/lib/action_kit_rest/base.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionKitRest
|
2
4
|
class Base < Vertebrae::Model
|
3
|
-
|
4
5
|
def list(filters = {})
|
5
6
|
client.get_request(normalized_base_path, filters)
|
6
7
|
end
|
@@ -31,11 +32,11 @@ module ActionKitRest
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def extract_id_from_response(resp)
|
34
|
-
extract_id_from_location(resp.response.headers[
|
35
|
+
extract_id_from_location(resp.response.headers['location'])
|
35
36
|
end
|
36
37
|
|
37
38
|
def extract_id_from_location(location)
|
38
|
-
location.scan(
|
39
|
+
location.scan(%r{/(\d+)/$}).first.first
|
39
40
|
end
|
40
41
|
end
|
41
|
-
end
|
42
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'action_kit_rest/api'
|
2
4
|
|
3
5
|
module ActionKitRest
|
@@ -9,19 +11,19 @@ module ActionKitRest
|
|
9
11
|
self.clients = {}
|
10
12
|
end
|
11
13
|
|
12
|
-
[
|
14
|
+
%i[import signup donation unsubscribe event_campaign].each do |page_type|
|
13
15
|
define_method "#{page_type}_page" do
|
14
16
|
clients["#{page_type}_page"] ||= ("ActionKitRest::Pages::#{page_type.to_s.classify}Page".constantize).new(client: self)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
[
|
20
|
+
%i[unsubscribe event_create event_signup].each do |action|
|
19
21
|
define_method "#{action}_action" do
|
20
22
|
clients["#{action}_action"] ||= ("ActionKitRest::Actions::#{action.to_s.classify}Action".constantize).new(client: self)
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
|
-
[
|
26
|
+
%i[action page tag list user phone event language event_signup allowed_user_field].each do |thing|
|
25
27
|
define_method thing do
|
26
28
|
clients[thing] ||= ("ActionKitRest::#{thing.to_s.classify}".constantize).new(client: self)
|
27
29
|
end
|
data/lib/action_kit_rest/list.rb
CHANGED
data/lib/action_kit_rest/page.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionKitRest
|
2
4
|
module Pages
|
3
5
|
class Base < ActionKitRest::Base
|
@@ -6,15 +8,12 @@ module ActionKitRest
|
|
6
8
|
response = list(name: name)
|
7
9
|
response.obj.first
|
8
10
|
end
|
9
|
-
|
11
|
+
|
10
12
|
def find_or_create(params)
|
11
13
|
page = find(params[:name])
|
12
|
-
if page.blank?
|
13
|
-
page = create(params)
|
14
|
-
end
|
14
|
+
page = create(params) if page.blank?
|
15
15
|
page
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionKitRest
|
2
4
|
module Pages
|
3
5
|
class EventCampaignPage < ActionKitRest::Pages::Base
|
@@ -41,7 +43,7 @@ module ActionKitRest
|
|
41
43
|
|
42
44
|
def create_event_create_page(event_campaign, tags)
|
43
45
|
params = event_create_page_params(event_campaign, tags)
|
44
|
-
|
46
|
+
_response = client.post_json_request('eventcreatepage/', params)
|
45
47
|
|
46
48
|
params[:name]
|
47
49
|
end
|
@@ -57,7 +59,7 @@ module ActionKitRest
|
|
57
59
|
|
58
60
|
def create_event_signup_page(event_campaign, tags)
|
59
61
|
params = event_signup_page_params(event_campaign, tags)
|
60
|
-
|
62
|
+
_response = client.post_json_request('eventsignuppage/', params)
|
61
63
|
|
62
64
|
params[:name]
|
63
65
|
end
|