spree_seven 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: 28224145179128d4b4505a383efc0bb32c067efad479123b0bfa77bc002ef252
4
+ data.tar.gz: 6e61ca11e6bd61dae4a0bb015d44696bec745ff989297dfcc67a7be7cca343df
5
+ SHA512:
6
+ metadata.gz: 5f14e109d7c8261f06f96ddfb13b67c9da3f5ccc51ebed16f91bdd9ddd6c417de3598a91c1467651f6503930b2ddc3831fcd2a211c7adfb3c502bbd2497acceb
7
+ data.tar.gz: 739443d5abac3a928c29be267dfa7c1dba4e0b96df943dbd776d6b48dfd37b9b8cc062beaceba692f1359514d27e1f9810ff98d77d21f23777b92cc1eb0023cd
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .localeapp/locales
7
+ .project
8
+ .vscode
9
+ coverage
10
+ default
11
+ Gemfile.lock
12
+ tmp
13
+ nbproject
14
+ pkg
15
+ *.sw?
16
+ spec/dummy
17
+ .rvmrc
18
+ .sass-cache
19
+ public/spree
20
+ .ruby-version
21
+ .ruby-gemset
22
+ *.gem
23
+ */*.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ -r spec_helper
3
+ -f documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,24 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ TargetRubyVersion: 2.5
4
+ Include:
5
+ - '**/Gemfile'
6
+ - '**/Rakefile'
7
+ - '**/Appraisals'
8
+ Exclude:
9
+ - 'spec/dummy/**/*'
10
+ - 'lib/generators/**/*'
11
+
12
+ Rails:
13
+ Enabled: true
14
+
15
+ Metrics/LineLength:
16
+ Max: 150
17
+
18
+ # DISABLED
19
+
20
+ Style/Documentation:
21
+ Enabled: false
22
+
23
+ Style/FrozenStringLiteralComment:
24
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,37 @@
1
+ os: linux
2
+ dist: bionic
3
+
4
+ addons:
5
+ apt:
6
+ sources:
7
+ - google-chrome
8
+ packages:
9
+ - google-chrome-stable
10
+
11
+ services:
12
+ - mysql
13
+ - postgresql
14
+
15
+ language: ruby
16
+
17
+ rvm:
18
+ - 2.7
19
+ - 3.0
20
+
21
+ env:
22
+ - DB=mysql
23
+ - DB=postgres
24
+
25
+ before_install:
26
+ - mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
27
+
28
+ before_script:
29
+ - CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'`
30
+ - CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
31
+ - curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O
32
+ - unzip chromedriver_linux64.zip -d ~/bin
33
+ - nvm install 16
34
+
35
+ script:
36
+ - bundle exec rake test_app
37
+ - bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
8
+ gem 'spree', github: 'spree/spree', branch: 'main'
9
+ gem 'rails-controller-testing'
10
+
11
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present seven communications GmbH & Co. KG
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ <img src="https://www.seven.io/wp-content/uploads/Logo.svg" width="250" />
2
+
3
+ # SpreeSeven
4
+
5
+ This gem adds the functionality to send SMS via seven.
6
+
7
+ ## Installation
8
+
9
+ 1. Add this extension to your Gemfile with this line:
10
+
11
+ ```ruby
12
+ gem 'spree_seven'
13
+ ```
14
+
15
+ 2. Install the gem using Bundler
16
+
17
+ ```ruby
18
+ bundle install
19
+ ```
20
+
21
+ 3. Copy & run migrations
22
+
23
+ ```ruby
24
+ bundle exec rails g spree_seven:install
25
+ ```
26
+
27
+ 4. Restart your server
28
+
29
+ If your server was running, restart it so that it can find the assets properly.
30
+
31
+ ## Functionalities
32
+ ### Bulk SMS
33
+ Send SMS to all your customers at once.
34
+ You can filter by country, to target only customers from a specific country.
35
+
36
+ ## Testing
37
+
38
+ First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `rake test_app`.
39
+
40
+ ```shell
41
+ bundle update
42
+ bundle exec rake
43
+ ```
44
+
45
+ When testing your applications integration with this extension you may use it's factories.
46
+ Simply add this require statement to your spec_helper:
47
+
48
+ ```ruby
49
+ require 'spree_seven/factories'
50
+ ```
51
+
52
+ ## Releasing
53
+
54
+ ```shell
55
+ bundle exec gem bump -p -t
56
+ bundle exec gem release
57
+ ```
58
+
59
+ For more options please see [gem-release REAMDE](https://github.com/svenfuchs/gem-release)
60
+
61
+ ## Contributing
62
+
63
+ If you'd like to contribute, please take a look at the
64
+ [instructions](CONTRIBUTING.md) for installing dependencies and crafting a good
65
+ pull request.
66
+
67
+ ##### Support
68
+
69
+ Need help? Feel free to [contact us](https://www.seven.io/en/company/contact/).
70
+
71
+ [![MIT](https://img.shields.io/badge/License-MIT-teal.svg)](LICENSE)
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/extension_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default do
10
+ if Dir['spec/dummy'].empty?
11
+ Rake::Task[:test_app].invoke
12
+ Dir.chdir('../../')
13
+ end
14
+ Rake::Task[:spec].invoke
15
+ end
16
+
17
+ desc 'Generates a dummy app for testing'
18
+ task :test_app do
19
+ ENV['LIB_NAME'] = 'spree_seven'
20
+ Rake::Task['extension:test_app'].invoke
21
+ end
@@ -0,0 +1,19 @@
1
+ module Spree
2
+ module Admin
3
+ class SevenSettingsController < ResourceController
4
+ def update
5
+ settings = Spree::SevenSetting.new
6
+
7
+ preferences = params&.key?(:preferences) ? params.delete(:preferences) : params
8
+ preferences.each do |name, value|
9
+ next unless settings.has_preference? name
10
+ settings[name] = value
11
+ end
12
+
13
+ flash[:success] = Spree.t(:successfully_updated, resource: Spree.t('seven.settings'))
14
+
15
+ redirect_to edit_admin_seven_settings_path
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+ require 'net/http'
5
+ require 'net/https'
6
+ require 'json'
7
+
8
+ module Spree
9
+ module Admin
10
+ class SmsController < Spree::Admin::BaseController
11
+ attr_accessor :user_errors
12
+
13
+ def initialize
14
+ super
15
+ @user_errors = []
16
+ end
17
+
18
+ def index
19
+ render 'spree/admin/sms/index'
20
+ end
21
+
22
+ def submit
23
+ @user_message = send_sms
24
+ render json: {'response': @user_message}
25
+ end
26
+
27
+ private
28
+
29
+ def build_recipients(as_array = false)
30
+ if params[:to] != ''
31
+ return as_array ? [params[:to]] : params[:to]
32
+ end
33
+
34
+ to = []
35
+
36
+ Spree::Address.not_deleted.each { |a|
37
+ Rails.logger.info a.inspect
38
+
39
+ next if !a.deleted_at.nil? && params[:filter_include_deleted_addresses] == '0'
40
+ next if params[:filter_address_country] != '' && params[:filter_address_country] != !a.country_id
41
+
42
+ to.push(a.phone)
43
+ }
44
+
45
+ if to.empty?
46
+ @user_errors.push(I18n.t 'spree.seven.no_recipients')
47
+ end
48
+
49
+ to.uniq!
50
+
51
+ as_array ? to : to.join(',')
52
+ end
53
+
54
+ def api_key
55
+ source = nil
56
+ value = nil
57
+
58
+ if Spree::Seven::Config[:api_key]
59
+ source = 'Configuration'
60
+ value = Spree::Seven::Config[:api_key]
61
+ elsif ENV['SEVEN_API_KEY_SANDBOX']
62
+ source = 'Environment (Sandbox)'
63
+ value = ENV['SEVEN_API_KEY_SANDBOX']
64
+ elsif ENV['SEVEN_API_KEY']
65
+ source = 'Environment (Live)'
66
+ value = ENV['SEVEN_API_KEY']
67
+ end
68
+
69
+ Rails.logger.info "seven api_key: #{value} from #{source}"
70
+
71
+ value
72
+ end
73
+
74
+ def build_params
75
+ sms_params = params.to_unsafe_h.slice(
76
+ :flash,
77
+ :foreign_id,
78
+ :from,
79
+ :label,
80
+ :performance_tracking,
81
+ :text,
82
+ ).merge({ to: build_recipients })
83
+
84
+ Rails.logger.info sms_params
85
+
86
+ sms_params
87
+ end
88
+
89
+ def send_sms
90
+ if @user_errors.empty?
91
+ uri = URI('https://gateway.seven.io/api/sms')
92
+
93
+ res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
94
+ req = Net::HTTP::Post.new(uri)
95
+ req['Accept'] = 'application/json'
96
+ req['Content-Type'] = 'application/json'
97
+ req['X-Api-Key'] = api_key
98
+ req.body = build_params.to_json
99
+
100
+ http.request req
101
+ end
102
+
103
+ Rails.logger.info res.body
104
+
105
+ # flash[:success] = res.body
106
+
107
+ res.body
108
+ else
109
+ Rails.logger.info 'FoundUserErrors'
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,8 @@
1
+ module Spree
2
+ class SevenSetting < Preferences::Configuration
3
+ # Some example preferences are shown below, for more information visit:
4
+ # https://dev-docs.spreecommerce.org/internals/preferences
5
+
6
+ preference :api_key, :string
7
+ end
8
+ end
@@ -0,0 +1,22 @@
1
+ <% content_for :page_title do %>
2
+ <%= Spree.t('seven.settings') %>
3
+ <% end %>
4
+
5
+ <%= form_tag admin_seven_settings_path, method: :put do %>
6
+ <div class='row'>
7
+ <div class='col-12 col-md-6' data-hook='seven'>
8
+ <div class='form-group'>
9
+ <%= label_tag 'api_key', Spree.t('seven.api_key') %>
10
+ <%= password_field_tag 'api_key', Spree::Seven::Config[:api_key], class: 'form-control' %>
11
+ </div>
12
+ </div>
13
+ </div>
14
+
15
+ <div class='row'>
16
+ <div class='col'>
17
+ <div class='form-actions' data-hook='buttons'>
18
+ <%= button Spree.t('seven.actions.update'), 'update' %>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ <% end %>
@@ -0,0 +1,132 @@
1
+ <% content_for :page_title do %>
2
+ <%= Spree.t('seven.sms') %>
3
+ <% end %>
4
+
5
+ <% @user_errors.each do |err| %>
6
+ <div class='alert alert-danger'>
7
+ <%= err %>
8
+ </div>
9
+ <% end %>
10
+
11
+ <%= content_tag :h2, Spree.t('seven.response') %>
12
+ <pre id='response'><%= @user_message %></pre>
13
+
14
+
15
+ <%= form_with local: false, url: admin_seven_sms_url(only_path: true), method: :post, id: 'sevenSMS' do |f| %>
16
+ <div class='row'>
17
+ <div class='col-12 col-md-6'>
18
+ <fieldset>
19
+ <legend><%= Spree.t('seven.filter.address') %></legend>
20
+
21
+ <div class='form-group justify-content-between d-flex'>
22
+ <%= f.label :filter_include_deleted_addresses, Spree.t('seven.filter.include_deleted_addresses') %>
23
+ <%= f.check_box :filter_include_deleted_addresses %>
24
+ </div>
25
+
26
+ <div class='form-group'>
27
+ <div class='field'>
28
+ <%= f.label :filter_address_country, Spree::Country.model_name.human %>
29
+ <%= select_tag "filter_address_country", options_from_collection_for_select(all_countries, 'id', 'name'), class: 'custom-select form-control js-country_id', include_blank: true %>
30
+ </div>
31
+ </div>
32
+ </fieldset>
33
+
34
+ <hr>
35
+
36
+ <div class='form-group justify-content-between d-flex'>
37
+ <%= f.label :performance_tracking, Spree.t('seven.performance_tracking') %>
38
+ <%= f.check_box :performance_tracking %>
39
+ </div>
40
+
41
+ <div class='form-group justify-content-between d-flex'>
42
+ <%= f.label :flash, Spree.t('seven.flash') %>
43
+ <%= f.check_box :flash %>
44
+ </div>
45
+
46
+ <div class='form-group'>
47
+ <%= f.label :label, Spree.t('seven.label') %>
48
+ <%= text_field_tag(:label, nil, {class: 'form-control', maxlength: 100}) %>
49
+ </div>
50
+
51
+ <div class='form-group'>
52
+ <%= f.label :foreign_id, Spree.t('seven.foreign_id') %>
53
+ <%= text_field_tag(:foreign_id, nil, {class: 'form-control', maxlength: 64}) %>
54
+ </div>
55
+
56
+ <div class='form-group'>
57
+ <%= f.label :from, Spree.t('seven.from') %>
58
+ <%= text_field_tag(:from, nil, {class: 'form-control', maxlength: 16}) %>
59
+ </div>
60
+
61
+ <div class='form-group'>
62
+ <%= f.label :to, Spree.t('seven.to') %>
63
+ <%= text_field_tag(:to, nil, {class: 'form-control'}) %>
64
+ </div>
65
+ </div>
66
+
67
+ <div class='col-12 col-md-6'>
68
+ <div class='form-group'>
69
+ <%= f.label :text, Spree.t('seven.text') %>
70
+ <%= text_area_tag :text, nil, {
71
+ class: 'form-control required',
72
+ maxlength: 1520,
73
+ required: true,
74
+ rows: 10
75
+ } %>
76
+ </div>
77
+ </div>
78
+
79
+ <div class='form-actions' data-hook='buttons'>
80
+ <%= f.submit Spree.t('seven.send'), {'class': 'btn btn-primary'} %>
81
+ </div>
82
+ </div>
83
+ <% end %>
84
+
85
+ <script>
86
+ document.addEventListener('DOMContentLoaded', () => {
87
+ const urlParams = new URLSearchParams(window.location.search)
88
+ const $form = document.getElementById('sevenSMS')
89
+ const $to = $form.elements.namedItem('to')
90
+ const to = urlParams.get('to');
91
+ const $countryFilter = $form.elements.namedItem('filter_address_country')
92
+ const $deletedFilter = document.getElementById('filter_include_deleted_addresses')
93
+ const $csrfToken = $form.elements.namedItem('authenticity_token')
94
+ const $submit = $form.elements.namedItem('commit')
95
+ const $response = document.getElementById('response')
96
+
97
+ $submit.addEventListener('click', async e => {
98
+ e.preventDefault()
99
+
100
+ $submit.setAttribute('disabled', 'disabled')
101
+
102
+ const fd = new FormData($form)
103
+ const params = new URLSearchParams(fd)
104
+ const res = await fetch('/admin/seven/sms', {
105
+ body: JSON.stringify(params),
106
+ headers: {
107
+ 'X-CSRF-Token': $csrfToken.value
108
+ },
109
+ method: 'POST'
110
+ })
111
+ const {response} = await res.json()
112
+ $response.innerText = response
113
+
114
+ $submit.removeAttribute('disabled')
115
+ })
116
+
117
+ $to.addEventListener('input', () => {
118
+ if ($to.value !== '') {
119
+ $countryFilter.setAttribute('disabled', 'disabled')
120
+ $deletedFilter.setAttribute('disabled', 'disabled')
121
+ } else {
122
+ $countryFilter.removeAttribute('disabled')
123
+ $deletedFilter.removeAttribute('disabled')
124
+ }
125
+ })
126
+
127
+ if (to?.length) {
128
+ $to.value = to
129
+ $to.dispatchEvent(new Event('input', {'bubbles': true}))
130
+ }
131
+ })
132
+ </script>
data/bin/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" from the root of your extension
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/spree_seven/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,17 @@
1
+ Rails.application.config.after_initialize do
2
+ Rails.application.config.spree_backend.main_menu.add(
3
+ Spree::Admin::MainMenu::SectionBuilder
4
+ .new('seven', 'envelope.svg')
5
+ .with_label_translation_key('seven.name')
6
+ .with_items(
7
+ [
8
+ Spree::Admin::MainMenu::ItemBuilder.new('seven.sms', '/admin/seven/sms')
9
+ .build,
10
+ Spree::Admin::MainMenu::ItemBuilder.new('seven.settings', '/admin/seven_settings/edit')
11
+ .build
12
+ ]
13
+ )
14
+ .build
15
+ )
16
+
17
+ end
@@ -0,0 +1,20 @@
1
+ Rails.application.config.after_initialize do
2
+ Rails.application.config.spree_backend.actions[:user].add(
3
+ Spree::Admin::Actions::ActionBuilder.new('seven.sms', -> (resource) {
4
+ include Spree::Core::Engine.routes.url_helpers
5
+
6
+ user = Spree::User.find_by(id: resource.id)
7
+ ship_address = user.ship_address
8
+ bill_address = user.bill_address
9
+ ship_phone = ship_address && ship_address['phone'] ? ship_address['phone'] : ''
10
+ bill_phone = bill_address && bill_address['phone'] ? bill_address['phone'] : ''
11
+ to = ship_phone ? ship_phone : bill_phone
12
+
13
+ return admin_seven_sms_url(to: to, only_path: true)
14
+ }).
15
+ with_icon_key('envelope.svg').
16
+ with_style(Spree::Admin::Actions::ActionStyle::SECONDARY).
17
+ with_method(:post).
18
+ build
19
+ )
20
+ end
@@ -0,0 +1,25 @@
1
+ ---
2
+ de:
3
+ spree:
4
+ admin:
5
+ tab:
6
+ seven: seven
7
+ seven:
8
+ api_key: API-Schlüssel
9
+ errors: Fehler
10
+ filter:
11
+ address: Address-Filter
12
+ include_deleted_addresses: Gelöschte Adressen inkludieren
13
+ flash: Flash
14
+ foreign_id: Foreign ID
15
+ from: Von
16
+ label: Label
17
+ name: Seven
18
+ no_recipients: Keine Empfangsziele gefunden mit dieser Konfiguration.
19
+ performance_tracking: Performance Tracking
20
+ response: Antwort
21
+ send: Senden
22
+ settings: Einstellungen
23
+ sms: SMS
24
+ text: Text
25
+ to: An
@@ -0,0 +1,25 @@
1
+ ---
2
+ en:
3
+ spree:
4
+ admin:
5
+ tab:
6
+ seven: seven
7
+ seven:
8
+ api_key: API Key
9
+ errors: Errors
10
+ filter:
11
+ address: Address Filters
12
+ include_deleted_addresses: Include deleted addresses
13
+ flash: Flash
14
+ foreign_id: Foreign ID
15
+ from: From
16
+ label: Label
17
+ name: Seven
18
+ no_recipients: No recipients found for the given configuration.
19
+ performance_tracking: Performance Tracking
20
+ response: Response
21
+ send: Send
22
+ settings: Settings
23
+ sms: SMS
24
+ text: Text
25
+ to: To
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ Spree::Core::Engine.add_routes do
2
+ namespace :admin do
3
+ get '/seven/sms', to: 'sms#index', as: :seven_sms
4
+ post '/seven/sms', to: 'sms#submit'
5
+
6
+ resource :seven_settings, only: [:edit, :update]
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ module SpreeSeven
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ class_option :migrate, type: :boolean, default: true
5
+
6
+ def add_migrations
7
+ run 'bundle exec rake railties:install:migrations FROM=spree_seven'
8
+ end
9
+
10
+ def run_migrations
11
+ run_migrations = options[:migrate] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
12
+ if run_migrations
13
+ run 'bundle exec rails db:migrate'
14
+ else
15
+ puts 'Skipping rails db:migrate, don\'t forget to run it!'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,29 @@
1
+ module SpreeSeven
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_seven'
6
+
7
+ config.autoload_paths += %W[#{config.root}/lib]
8
+
9
+ config.generators do |g| # use rspec for tests
10
+ g.test_framework :rspec
11
+ end
12
+
13
+ initializer 'spree_seven.environment', before: :load_config_initializers do |_app|
14
+ Config = Configuration.new
15
+ end
16
+
17
+ config.after_initialize do
18
+ Spree::Seven::Config = Spree::SevenSetting.new
19
+ end
20
+
21
+ def self.activate
22
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
23
+ Rails.configuration.cache_classes ? require(c) : load(c)
24
+ end
25
+ end
26
+
27
+ config.to_prepare(&method(:activate).to_proc)
28
+ end
29
+ end
@@ -0,0 +1,11 @@
1
+ module SpreeSeven
2
+ VERSION = '0.0.1'.freeze
3
+
4
+ module_function
5
+
6
+ # Returns the version of the currently loaded SpreeSeven as a
7
+ # <tt>Gem::Version</tt>.
8
+ def version
9
+ Gem::Version.new VERSION
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ require 'spree_core'
2
+ require 'spree_backend'
3
+ require 'spree_extension'
4
+ require 'spree_seven/engine'
5
+ require 'spree_seven/version'
6
+
7
+ module Spree
8
+ module Seven
9
+ module_function
10
+ def config(*)
11
+ yield(Spree::Seven::Config)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ class SpreeSevenHooks < Spree::ThemeSupport::HookListener
2
+ insert_after :admin_configurations_menu do
3
+ %(<tr><td><%= link_to t("sms_manage"), admin_sms_path %></td>
4
+ <td><%= t("sms_manage_desc") %></td></tr>)
5
+ end
6
+ insert_after :admin_configurations_sidebar_menu do
7
+ %(<li<%= raw(' class="active"') if controller.controller_name == 'sms_manage' %>><%= link_to t("sms_manage"), admin_sms_path %></li>)
8
+ end
9
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: UTF-8
2
+ lib = File.expand_path('../lib/', __FILE__)
3
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'spree_seven/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.platform = Gem::Platform::RUBY
9
+ s.name = 'spree_seven'
10
+ s.version = SpreeSeven.version
11
+ s.summary = 'Send SMS to your customers via seven.'
12
+ s.description = s.summary
13
+ s.required_ruby_version = '>= 3.0'
14
+
15
+ s.author = 'seven communications GmbH & Co. KG'
16
+ s.email = 'support@seven.io'
17
+ s.homepage = 'https://github.com/seven-io/spree'
18
+ s.license = 'MIT'
19
+
20
+ s.files = `git ls-files`.split("\n").reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
21
+ s.require_path = 'lib'
22
+ s.requirements << 'none'
23
+
24
+ spree_version = '>= 4.7.0'
25
+ s.add_dependency 'spree', spree_version
26
+ s.add_dependency 'spree_backend', spree_version
27
+ s.add_dependency 'spree_extension'
28
+
29
+ s.add_development_dependency 'spree_dev_tools'
30
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_seven
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - seven communications GmbH & Co. KG
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-11-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: spree
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.7.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.7.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: spree_backend
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 4.7.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 4.7.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: spree_extension
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: spree_dev_tools
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Send SMS to your customers via seven.
70
+ email: support@seven.io
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - ".gitignore"
76
+ - ".rspec"
77
+ - ".rubocop.yml"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - app/controllers/spree/admin/seven_settings_controller.rb
84
+ - app/controllers/spree/admin/sms_controller.rb
85
+ - app/models/spree/seven_setting.rb
86
+ - app/views/spree/admin/seven_settings/edit.erb
87
+ - app/views/spree/admin/sms/index.erb
88
+ - bin/rails
89
+ - config/initializers/menu.rb
90
+ - config/initializers/users.rb
91
+ - config/locales/de.yml
92
+ - config/locales/en.yml
93
+ - config/routes.rb
94
+ - lib/generators/spree_seven/install/install_generator.rb
95
+ - lib/spree_seven.rb
96
+ - lib/spree_seven/engine.rb
97
+ - lib/spree_seven/version.rb
98
+ - lib/spree_seven_hooks.rb
99
+ - spree_seven.gemspec
100
+ homepage: https://github.com/seven-io/spree
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '3.0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements:
119
+ - none
120
+ rubygems_version: 3.5.16
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Send SMS to your customers via seven.
124
+ test_files: []