action_kit_rest 0.4.2 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +24 -0
  3. data/.rubocop.yml +26 -0
  4. data/.ruby-version +1 -1
  5. data/Gemfile +11 -9
  6. data/README.md +2 -2
  7. data/Rakefile +15 -18
  8. data/action_kit_rest.gemspec +24 -20
  9. data/lib/action_kit_rest/action.rb +3 -1
  10. data/lib/action_kit_rest/actions/event_create_action.rb +5 -3
  11. data/lib/action_kit_rest/actions/event_signup_action.rb +6 -3
  12. data/lib/action_kit_rest/actions/unsubscribe_action.rb +3 -1
  13. data/lib/action_kit_rest/allowed_user_field.rb +3 -1
  14. data/lib/action_kit_rest/api.rb +9 -7
  15. data/lib/action_kit_rest/base.rb +5 -4
  16. data/lib/action_kit_rest/client.rb +5 -3
  17. data/lib/action_kit_rest/event.rb +3 -1
  18. data/lib/action_kit_rest/event_signup.rb +3 -1
  19. data/lib/action_kit_rest/language.rb +3 -1
  20. data/lib/action_kit_rest/list.rb +3 -1
  21. data/lib/action_kit_rest/page.rb +4 -2
  22. data/lib/action_kit_rest/pages/base.rb +4 -5
  23. data/lib/action_kit_rest/pages/donation_page.rb +3 -1
  24. data/lib/action_kit_rest/pages/event_campaign_page.rb +4 -2
  25. data/lib/action_kit_rest/pages/import_page.rb +3 -1
  26. data/lib/action_kit_rest/pages/signup_page.rb +3 -1
  27. data/lib/action_kit_rest/pages/unsubscribe_page.rb +3 -1
  28. data/lib/action_kit_rest/phone.rb +2 -0
  29. data/lib/action_kit_rest/railties.rb +3 -1
  30. data/lib/action_kit_rest/response/collection.rb +4 -4
  31. data/lib/action_kit_rest/response/raise_error.rb +15 -12
  32. data/lib/action_kit_rest/response/validation_error.rb +8 -1
  33. data/lib/action_kit_rest/response/wrapper.rb +10 -10
  34. data/lib/action_kit_rest/tag.rb +6 -6
  35. data/lib/action_kit_rest/user.rb +3 -1
  36. data/lib/action_kit_rest/version.rb +3 -1
  37. data/lib/action_kit_rest.rb +2 -0
  38. data/spec/lib/action_kit_rest/actions/event_create_action_spec.rb +6 -4
  39. data/spec/lib/action_kit_rest/actions/event_signup_action_spec.rb +6 -4
  40. data/spec/lib/action_kit_rest/allowed_user_field_spec.rb +9 -7
  41. data/spec/lib/action_kit_rest/logger_spec.rb +7 -5
  42. data/spec/lib/action_kit_rest/page_spec.rb +28 -28
  43. data/spec/lib/action_kit_rest/pages/event_campaign_page_spec.rb +25 -20
  44. data/spec/lib/action_kit_rest/pages/import_page_spec.rb +21 -17
  45. data/spec/lib/action_kit_rest/response/collection_spec.rb +13 -11
  46. data/spec/lib/action_kit_rest/response/validation_error_spec.rb +39 -0
  47. data/spec/lib/action_kit_rest/response/wrapper_spec.rb +6 -4
  48. data/spec/lib/action_kit_rest/user_spec.rb +11 -9
  49. data/spec/spec_helper.rb +6 -4
  50. data/spec/support/shared_contexts/stub_logger.rb +4 -2
  51. metadata +61 -57
  52. data/.travis.yml +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca64b1d81e81abcc181f8389df3b0a5a6c6a808a5247095d127c8c259f61d668
4
- data.tar.gz: d1446906a1e323bc240ea661517eaba948fce26c34df8e5655359a2df6a85488
3
+ metadata.gz: 2116d0818685f8278921f966f7f4dfb53d4121c983642bb431a13267de077195
4
+ data.tar.gz: 19e5351054a60071bef7926ea245ad4f1392a7aa33e929ef44fbb590f18335d1
5
5
  SHA512:
6
- metadata.gz: 1948223a468182d3f5e8b8636a5216be2f98df7c9e936e4b074a2550058cd84e3fd0cd07e8805f26807daf0f713884d2ec961ba7324ad52137253a31979533a5
7
- data.tar.gz: e867c075b7d9f25cc943f465b86b2ebd2cd66f7bb9c8310c528f615ef60e664b336dc3e612a7fc0511205a8662d5199b29e5db9fad93f06d937ee59da6897534
6
+ metadata.gz: 61722ea2d57c2da9e942351d1651ddfc8b3c2d8df337736aab9d9ce57d4f28993ac8be1f83f6e2f5b88a6f463e21849d5df353ac3d155791be8e57ce4ce2884d
7
+ data.tar.gz: efa307aa27a974fa7a93eba9ebf3ebacc6e6b4ba7a11abc63cbaed748c27d5346477dfa19cc8d01d93e4e3986363fed50de7b110f4d02b621e9301e0f14229e9
@@ -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.5.3
1
+ 2.7.4
data/Gemfile CHANGED
@@ -1,15 +1,17 @@
1
- source "http://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- gem 'vertebrae', '~> 0.5.0'
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', '>= 10.0.2', '<11.0'
9
8
  gem 'bundler', '>= 2.0', '<3.0'
10
- gem 'eventmachine', '>=1.2.5', '<2.0'
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 'juwelier', '>=2.4.9', '<3.0'
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
- # action_kit_rest
1
+ # action\_kit\_rest
2
2
 
3
3
  A ruby binding for the ActionKit REST API
4
4
 
5
- [![Build Status](https://travis-ci.org/controlshift/action_kit_rest.svg)](https://travis-ci.org/controlshift/action_kit_rest)
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
- # encoding: utf-8
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
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
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.rb'
14
-
13
+ require './lib/action_kit_rest/version'
15
14
 
16
15
  require 'juwelier'
17
16
  Juwelier::Tasks.new do |gem|
18
- # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
19
- gem.name = "action_kit_rest"
17
+ gem.name = 'action_kit_rest'
20
18
  gem.version = ActionKitRest::VERSION::STRING
21
- gem.homepage = "http://github.com/controlshift/action_kit_rest"
22
- gem.license = "MIT"
23
- gem.summary = %Q{A wrapper for the ActionKit REST API}
24
- gem.description = %Q{Gem for interacting with the ActionKit API}
25
- gem.email = "systems@controlshiftlabs.com"
26
- gem.authors = ["Nathan Woodhull", 'Diego Marcet', 'Jacinda Moore']
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 :default => :spec
31
+ task default: :spec
35
32
 
36
- desc "Run specs"
33
+ desc 'Run specs'
37
34
  RSpec::Core::RakeTask.new do |t|
38
- t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
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}"
@@ -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.2 ruby lib
5
+ # stub: action_kit_rest 0.4.6 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "action_kit_rest".freeze
9
- s.version = "0.4.2"
9
+ s.version = "0.4.6"
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, "Jacinda Moore".freeze]
14
- s.date = "2020-01-13"
13
+ s.authors = ["Nathan Woodhull".freeze, "Diego Marcet".freeze, "Grey Moore".freeze]
14
+ s.date = "2021-09-29"
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",
@@ -81,6 +82,7 @@ Gem::Specification.new do |s|
81
82
  "spec/lib/action_kit_rest/pages/event_campaign_page_spec.rb",
82
83
  "spec/lib/action_kit_rest/pages/import_page_spec.rb",
83
84
  "spec/lib/action_kit_rest/response/collection_spec.rb",
85
+ "spec/lib/action_kit_rest/response/validation_error_spec.rb",
84
86
  "spec/lib/action_kit_rest/response/wrapper_spec.rb",
85
87
  "spec/lib/action_kit_rest/user_spec.rb",
86
88
  "spec/spec_helper.rb",
@@ -88,7 +90,7 @@ Gem::Specification.new do |s|
88
90
  ]
89
91
  s.homepage = "http://github.com/controlshift/action_kit_rest".freeze
90
92
  s.licenses = ["MIT".freeze]
91
- s.rubygems_version = "3.1.1".freeze
93
+ s.rubygems_version = "3.1.6".freeze
92
94
  s.summary = "A wrapper for the ActionKit REST API".freeze
93
95
 
94
96
  if s.respond_to? :specification_version then
@@ -96,25 +98,27 @@ Gem::Specification.new do |s|
96
98
  end
97
99
 
98
100
  if s.respond_to? :add_runtime_dependency then
99
- s.add_runtime_dependency(%q<vertebrae>.freeze, ["~> 0.5.0"])
100
- s.add_development_dependency(%q<rspec>.freeze, ["~> 3.7"])
101
- s.add_development_dependency(%q<webmock>.freeze, ["~> 3.3"])
102
- s.add_development_dependency(%q<byebug>.freeze, [">= 10.0.2", "< 11.0"])
101
+ s.add_runtime_dependency(%q<vertebrae>.freeze, [">= 0.6.0"])
103
102
  s.add_development_dependency(%q<bundler>.freeze, [">= 2.0", "< 3.0"])
104
- s.add_development_dependency(%q<eventmachine>.freeze, [">= 1.2.5", "< 2.0"])
105
- s.add_development_dependency(%q<em-synchrony>.freeze, [">= 1.0.6", "< 2.0"])
103
+ s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
106
104
  s.add_development_dependency(%q<em-http-request>.freeze, [">= 1.1.5", "< 2.0"])
107
- s.add_development_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0"])
105
+ s.add_development_dependency(%q<em-synchrony>.freeze, [">= 1.0.6", "< 2.0"])
106
+ s.add_development_dependency(%q<eventmachine>.freeze, [">= 1.2.5", "< 2.0"])
107
+ s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
108
+ s.add_development_dependency(%q<rspec>.freeze, ["~> 3.7"])
109
+ s.add_development_dependency(%q<rubocop>.freeze, [">= 0"])
110
+ s.add_development_dependency(%q<webmock>.freeze, ["~> 3.3"])
108
111
  else
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, [">= 10.0.2", "< 11.0"])
112
+ s.add_dependency(%q<vertebrae>.freeze, [">= 0.6.0"])
113
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"])
114
+ s.add_dependency(%q<byebug>.freeze, [">= 0"])
116
115
  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"])
116
+ s.add_dependency(%q<em-synchrony>.freeze, [">= 1.0.6", "< 2.0"])
117
+ s.add_dependency(%q<eventmachine>.freeze, [">= 1.2.5", "< 2.0"])
118
+ s.add_dependency(%q<juwelier>.freeze, [">= 0"])
119
+ s.add_dependency(%q<rspec>.freeze, ["~> 3.7"])
120
+ s.add_dependency(%q<rubocop>.freeze, [">= 0"])
121
+ s.add_dependency(%q<webmock>.freeze, ["~> 3.3"])
118
122
  end
119
123
  end
120
124
 
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionKitRest
2
4
  class Action < Base
3
5
  def base_path
4
6
  'action'
5
7
  end
6
8
  end
7
- end
9
+ end
@@ -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(/\/rest\/v1\/event\/(\d*)\//)[1]
13
- ak_event_create_action.obj['user_id'] = ak_event_create_action.user.match(/\/rest\/v1\/user\/(\d*)\//)[1]
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'] = ak_event_signup_action.signup.match(/\/rest\/v1\/eventsignup\/(\d*)\//)[1]
13
- ak_event_signup_action.obj['user_id'] = ak_event_signup_action.user.match(/\/rest\/v1\/user\/(\d*)\//)[1]
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
  module Actions
3
5
  class UnsubscribeAction < Action
@@ -6,4 +8,4 @@ module ActionKitRest
6
8
  end
7
9
  end
8
10
  end
9
- end
11
+ 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["location"].split('/').last
19
+ resp.response.headers['location'].split('/').last
18
20
  end
19
21
  end
20
22
  end
@@ -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( super(*args) )
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.has_key?('data') && params['data'].present?
22
- return params['data']
22
+ if params.key?('data') && params['data'].present?
23
+ params['data']
23
24
  else
24
- return params
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, connection.configuration.password
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 ActionKitRest::Response::RaiseError
51
+ builder.use ActionKitRest::Response::RaiseError
50
52
  builder.adapter connection.configuration.adapter
51
53
  end
52
54
  end
@@ -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["location"])
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(/\/(\d+)\/$/).first.first
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
- [:import, :signup, :donation, :unsubscribe, :event_campaign].each do |page_type|
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
- [:unsubscribe, :event_create, :event_signup].each do |action|
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
- [:action, :page, :tag, :list, :user, :phone, :event, :language, :event_signup, :allowed_user_field].each do |thing|
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionKitRest
2
4
  class Event < Base
3
5
  def base_path
@@ -9,4 +11,4 @@ module ActionKitRest
9
11
  response.obj.first
10
12
  end
11
13
  end
12
- end
14
+ end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionKitRest
2
4
  class EventSignup < Base
3
5
  def base_path
4
6
  'eventsignup'
5
7
  end
6
8
  end
7
- end
9
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionKitRest
2
4
  class Language < Base
3
5
  def base_path
@@ -9,4 +11,4 @@ module ActionKitRest
9
11
  response.obj.first
10
12
  end
11
13
  end
12
- end
14
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionKitRest
2
4
  class List < Base
3
5
  def base_path
@@ -9,4 +11,4 @@ module ActionKitRest
9
11
  response.obj.first
10
12
  end
11
13
  end
12
- end
14
+ end
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionKitRest
2
4
  class Page < Vertebrae::Model
3
5
  def list
4
- client.get_request("page/")
6
+ client.get_request('page/')
5
7
  end
6
8
 
7
9
  def get(id)
8
10
  client.get_request("page/#{id}/")
9
11
  end
10
12
  end
11
- end
13
+ end
@@ -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 DonationPage < ActionKitRest::Pages::Base
@@ -6,4 +8,4 @@ module ActionKitRest
6
8
  end
7
9
  end
8
10
  end
9
- end
11
+ end
@@ -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
- response = client.post_json_request('eventcreatepage/', params)
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
- response = client.post_json_request('eventsignuppage/', params)
62
+ _response = client.post_json_request('eventsignuppage/', params)
61
63
 
62
64
  params[:name]
63
65
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionKitRest
2
4
  module Pages
3
5
  class ImportPage < ActionKitRest::Pages::Base
@@ -6,4 +8,4 @@ module ActionKitRest
6
8
  end
7
9
  end
8
10
  end
9
- end
11
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionKitRest
2
4
  module Pages
3
5
  class SignupPage < ActionKitRest::Pages::Base
@@ -6,4 +8,4 @@ module ActionKitRest
6
8
  end
7
9
  end
8
10
  end
9
- end
11
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionKitRest
2
4
  module Pages
3
5
  class UnsubscribePage < ActionKitRest::Pages::Base
@@ -6,4 +8,4 @@ module ActionKitRest
6
8
  end
7
9
  end
8
10
  end
9
- end
11
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionKitRest
2
4
  class Phone < Base
3
5
  def base_path
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionKitRest
2
4
  class Railties < ::Rails::Railtie
3
5
  initializer 'Rails logger' do
4
6
  ActionKitRest.logger = Rails.logger
5
7
  end
6
8
  end
7
- end
9
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # A class responsible for proxing to faraday response &
2
4
  # or a pagination collection.
3
5
  module ActionKitRest
@@ -5,9 +7,7 @@ module ActionKitRest
5
7
  class Collection
6
8
  include Enumerable
7
9
 
8
- attr_reader :meta
9
- attr_reader :objects
10
-
10
+ attr_reader :meta, :objects
11
11
 
12
12
  def initialize(meta, objects)
13
13
  @meta = meta
@@ -15,7 +15,7 @@ module ActionKitRest
15
15
  end
16
16
 
17
17
  def each(&block)
18
- # todo handle pagination somehow!
18
+ # TODO: handle pagination somehow!
19
19
  objects.each do |o|
20
20
  block.call(o)
21
21
  end