ishapi 0.1.8.316 → 3.0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +21 -12
  4. data/Rakefile +4 -22
  5. data/app/assets/config/ishapi_manifest.js +0 -1
  6. data/app/assets/stylesheets/ishapi/{application.scss → application.css} +2 -32
  7. data/app/controllers/ishapi/application_controller.rb +2 -139
  8. data/app/helpers/ishapi/application_helper.rb +0 -5
  9. data/app/mailers/ishapi/application_mailer.rb +4 -11
  10. data/app/models/ishapi/application_record.rb +5 -0
  11. data/app/views/layouts/ishapi/application.html.erb +15 -0
  12. data/config/routes.rb +0 -101
  13. data/lib/ishapi/engine.rb +0 -6
  14. data/lib/ishapi/version.rb +1 -1
  15. data/lib/ishapi.rb +2 -4
  16. metadata +13 -272
  17. data/app/assets/javascripts/ishapi/application.js +0 -14
  18. data/app/assets/stylesheets/ishapi/galleries.scss +0 -46
  19. data/app/assets/stylesheets/ishapi/locations.scss +0 -8
  20. data/app/assets/stylesheets/scaffold.css +0 -80
  21. data/app/controllers/ishapi/email_contexts_controller.rb +0 -28
  22. data/app/controllers/ishapi/email_conversations_controller.rb +0 -45
  23. data/app/controllers/ishapi/email_messages_controller.rb +0 -54
  24. data/app/controllers/ishapi/email_unsubscribes_controller.rb +0 -35
  25. data/app/controllers/ishapi/galleries_controller.rb +0 -56
  26. data/app/controllers/ishapi/gameui_controller.rb +0 -64
  27. data/app/controllers/ishapi/invoices_controller.rb +0 -22
  28. data/app/controllers/ishapi/lead_actions_controller.rb +0 -23
  29. data/app/controllers/ishapi/leads_controller.rb +0 -18
  30. data/app/controllers/ishapi/leadsets_controller.rb +0 -30
  31. data/app/controllers/ishapi/locations_controller.rb +0 -54
  32. data/app/controllers/ishapi/maps_controller.rb +0 -45
  33. data/app/controllers/ishapi/my/galleries_controller.rb +0 -11
  34. data/app/controllers/ishapi/my/reports_controller.rb +0 -11
  35. data/app/controllers/ishapi/my/videos_controller.rb +0 -10
  36. data/app/controllers/ishapi/newsitems_controller.rb +0 -35
  37. data/app/controllers/ishapi/obfuscated_redirects_controller.rb +0 -27
  38. data/app/controllers/ishapi/option_price_items_controller.rb +0 -44
  39. data/app/controllers/ishapi/order_items_controller.rb +0 -53
  40. data/app/controllers/ishapi/orders_controller.rb +0 -32
  41. data/app/controllers/ishapi/payments_controller.rb +0 -108
  42. data/app/controllers/ishapi/photos_controller.rb +0 -13
  43. data/app/controllers/ishapi/products_controller.rb +0 -16
  44. data/app/controllers/ishapi/stock_watches_controller.rb +0 -13
  45. data/app/controllers/ishapi/user_profiles_controller.rb +0 -27
  46. data/app/controllers/ishapi/users/registrations_controller.rb +0 -37
  47. data/app/controllers/ishapi/users/sessions_controller.rb +0 -36
  48. data/app/controllers/ishapi/users_controller.rb +0 -43
  49. data/app/controllers/ishapi/videos_controller.rb +0 -17
  50. data/app/jobs/ishapi/email_message_intake_job.rb +0 -178
  51. data/app/jobs/ishapi/email_message_intake_job.rb-todo +0 -6
  52. data/app/mailers/ishapi/confirmations_mailer.rb +0 -14
  53. data/app/models/ishapi/ability.rb +0 -130
  54. data/app/views/ishapi/addresses/_show.jbuilder +0 -12
  55. data/app/views/ishapi/application/_meta.jbuilder +0 -10
  56. data/app/views/ishapi/application/_metaline.haml +0 -12
  57. data/app/views/ishapi/application/_pagination.jbuilder +0 -11
  58. data/app/views/ishapi/application_mailer/forwarder_notify.html.erb +0 -16
  59. data/app/views/ishapi/email_contexts/summary.csv.erb +0 -4
  60. data/app/views/ishapi/email_messages/show.haml +0 -10
  61. data/app/views/ishapi/email_unsubscribes/create.haml +0 -5
  62. data/app/views/ishapi/galleries/_index.jbuilder +0 -11
  63. data/app/views/ishapi/galleries/_show.jbuilder +0 -24
  64. data/app/views/ishapi/galleries/index.jbuilder +0 -15
  65. data/app/views/ishapi/galleries/show.html.haml +0 -20
  66. data/app/views/ishapi/galleries/show.json.jbuilder +0 -12
  67. data/app/views/ishapi/galleries/show_premium_locked.jbuilder +0 -21
  68. data/app/views/ishapi/galleries/show_premium_unlocked.jbuilder +0 -17
  69. data/app/views/ishapi/locations/show.haml +0 -14
  70. data/app/views/ishapi/mailer/confirmation_instructions.html.erb +0 -6
  71. data/app/views/ishapi/mailer/email_changed.html.erb +0 -7
  72. data/app/views/ishapi/mailer/password_change.html.erb +0 -3
  73. data/app/views/ishapi/mailer/reset_password_instructions.html.erb +0 -8
  74. data/app/views/ishapi/mailer/unlock_instructions.html.erb +0 -7
  75. data/app/views/ishapi/maps/_show.jbuilder +0 -63
  76. data/app/views/ishapi/maps/_show_lite.jbuilder-trash +0 -16
  77. data/app/views/ishapi/maps/index.jbuilder +0 -12
  78. data/app/views/ishapi/maps/show.jbuilder +0 -6
  79. data/app/views/ishapi/maps/show_restricted.jbuilder +0 -44
  80. data/app/views/ishapi/markers/_card.haml +0 -28
  81. data/app/views/ishapi/markers/_index.jbuilder +0 -38
  82. data/app/views/ishapi/my/videos/index.jbuilder +0 -9
  83. data/app/views/ishapi/newsitems/_index.haml +0 -22
  84. data/app/views/ishapi/newsitems/_index.jbuilder +0 -86
  85. data/app/views/ishapi/newsitems/_show.haml +0 -10
  86. data/app/views/ishapi/newsitems/_show.haml-trash +0 -5
  87. data/app/views/ishapi/newsitems/index.jbuilder +0 -5
  88. data/app/views/ishapi/obfuscated_redirects/show.haml +0 -4
  89. data/app/views/ishapi/option_price_items/index.jbuilder +0 -17
  90. data/app/views/ishapi/option_price_items/view.jbuilder +0 -19
  91. data/app/views/ishapi/orders/_item.jbuilder +0 -8
  92. data/app/views/ishapi/orders/_show.jbuilder +0 -11
  93. data/app/views/ishapi/photos/_index.jbuilder +0 -19
  94. data/app/views/ishapi/photos/_show.jbuilder +0 -12
  95. data/app/views/ishapi/photos/show.jbuilder +0 -6
  96. data/app/views/ishapi/products/show.jbuilder +0 -16
  97. data/app/views/ishapi/reports/_index.jbuilder +0 -24
  98. data/app/views/ishapi/reports/index.jbuilder +0 -6
  99. data/app/views/ishapi/reports/show.haml +0 -15
  100. data/app/views/ishapi/reports/show.jbuilder +0 -51
  101. data/app/views/ishapi/stock_watches/index.jbuilder +0 -11
  102. data/app/views/ishapi/user_profiles/_account.jbuilder +0 -18
  103. data/app/views/ishapi/user_profiles/_index.jbuilder +0 -9
  104. data/app/views/ishapi/user_profiles/account.jbuilder +0 -2
  105. data/app/views/ishapi/user_profiles/login.jbuilder +0 -5
  106. data/app/views/ishapi/user_profiles/show.jbuilder +0 -9
  107. data/app/views/ishapi/user_profiles/show.jbuilder-bk +0 -24
  108. data/app/views/ishapi/videos/_index.jbuilder +0 -11
  109. data/app/views/ishapi/videos/_show.haml +0 -22
  110. data/app/views/ishapi/videos/_show.jbuilder +0 -37
  111. data/app/views/ishapi/videos/index.jbuilder +0 -3
  112. data/app/views/layouts/ishapi/application.html.haml +0 -38
@@ -1,64 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
-
3
- module Ishapi
4
- class GameuiController < ApplicationController
5
- before_action :check_long_term_token, except: []
6
-
7
- def buy_stars
8
- authorize! :buy_stars, @profile
9
- puts! @current_user, 'current_user'
10
- puts! @profile, 'profile'
11
-
12
- payment = Ish::Payment.new :email => @profile.email, :amount => params[:amount],
13
- profile: @profile
14
-
15
- ::Stripe.api_key = STRIPE_SK
16
- acct = Stripe::Account.create(
17
- :country => 'US',
18
- :type => 'custom'
19
- )
20
- charge = ::Stripe::Charge.create(
21
- :amount => params[:amount],
22
- :currency => 'usd',
23
- :source => params[:stripeToken],
24
- :destination => {
25
- :account => acct,
26
- }
27
- )
28
- puts! charge, 'charge'
29
- payment.charge = JSON.parse( charge.to_json )
30
- payment.save
31
- if payment.persisted?
32
- # add the star
33
- @profile.n_stars += 1
34
- @profile.save
35
- if !@profile.persisted?
36
- raise 'could not save profile, somehow'
37
- end
38
- else
39
- puts! payment.errors.messages
40
- end
41
-
42
- render json: { status: 'ok', n_stars: @profile.n_stars }
43
- end
44
-
45
- ## spend the star
46
- def do_purchase
47
- authorize! :do_purchase, ::Gameui
48
- item = params[:className].constantize.find_by_slug( params[:slug] )
49
-
50
- raise 'no such item' if !item
51
- raise 'too little funds' if @profile.n_stars < item.premium_tier
52
-
53
- ::IshModels::UserProfile.with_session do
54
- @profile.update_attributes( n_stars: @profile.n_stars - item.premium_tier )
55
- @purchase = ::Gameui::PremiumPurchase.create! user_profile: @profile, item: item
56
- end
57
-
58
- render json: @purchase
59
- rescue ::Exception => e
60
- render json: e
61
- end
62
-
63
- end
64
- end
@@ -1,22 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
- module Ishapi
3
- class InvoicesController < ApplicationController
4
-
5
- def search
6
- authorize! :open_permission, ::Ishapi
7
- begin
8
- i = Ish::Invoice.find_by( :number => params[:number] )
9
- if i.email == params[:email] && i.amount == params[:amount].to_f && i.payments.count == 0
10
- render :json => { :status => :ok }
11
- else
12
- render :status => 404, :json => {} # :json => { :status => 404, :code => 404, :message => 'Not Found1' }
13
- end
14
- rescue Mongoid::Errors::DocumentNotFound => e
15
- puts! e, 'e'
16
- render :status => 404, :json => {} # :json => { :status => 404, :code => 404, :message => 'Not Found1' }
17
- end
18
- end
19
-
20
- end
21
- end
22
-
@@ -1,23 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
-
3
- module Ishapi
4
- class LeadActionsController < ApplicationController
5
-
6
- def create
7
- if !params[:lead_id]
8
- render json: { status: :ok }
9
- return
10
- end
11
- tmpl = Office::LeadActionTemplate.find( params[:tmpl_id] )
12
- puts! tmpl, 'tmpl'
13
- lead_action = Office::LeadAction.find_or_create_by({
14
- lead_id: params[:lead_id],
15
- tmpl_id: params[:tmpl_id],
16
- })
17
- lead_action.params = params.to_json
18
- lead_action.save
19
- render json: { status: :ok, message: 'saved' }
20
- end
21
-
22
- end
23
- end
@@ -1,18 +0,0 @@
1
-
2
- require_dependency "ishapi/application_controller"
3
- module Ishapi
4
- class LeadsController < ApplicationController
5
-
6
- before_action :check_jwt
7
-
8
- def index
9
- authorize! :leads_index, ::Ishapi
10
- out = Lead.all.page( params[:leads_page] ).per( @current_profile.per_page )
11
- render json: {
12
- items: out,
13
- }
14
- end
15
-
16
- end
17
- end
18
-
@@ -1,30 +0,0 @@
1
-
2
- require_dependency "ishapi/application_controller"
3
- module Ishapi
4
- class LeadsetsController < ApplicationController
5
-
6
- load_and_authorize_resource
7
-
8
- def destroy
9
- authorize! :leadsets_destroy, ::Ishapi
10
-
11
- leadsets = Leadset.find( params[:leadset_ids] )
12
- @results = []
13
- leadsets.each do |leadset|
14
- @results.push leadset.discard
15
- end
16
- flash[:notice] = "Discard outcome: #{@results.inspect}."
17
- redirect_to action: 'index'
18
- end
19
-
20
- def index
21
- authorize! :leadsets_index, ::Ishapi
22
- out = Leadset.all
23
- render json: {
24
- items: out,
25
- }
26
- end
27
-
28
- end
29
- end
30
-
@@ -1,54 +0,0 @@
1
-
2
- require_dependency "ishapi/application_controller"
3
-
4
- ##
5
- ## supersedes Ishapi::MapsController
6
- ##
7
- class Ishapi::LocationsController < Ishapi::ApplicationController
8
-
9
- before_action :check_profile # , only: [ :show, :show_marker ]
10
-
11
- def show
12
- if 'self' == params[:slug] # @TODO: constantize _vp_ 2023-01-11
13
- @location = ::Gameui::Map.where( slug: @current_profile[:email] ).first
14
- else
15
- @location = ::Gameui::Map.where( slug: params[:slug] ).first
16
- @location ||= ::Gameui::Map.find params[:slug]
17
- end
18
-
19
- authorize! :show, @location
20
- map = @location.map || @location # @TODO: remove _vp_ 2023-03-20
21
-
22
- @newsitems = @location.newsitems.page( params[:newsitems_page]
23
- ).per( @location.newsitems_page_size )
24
-
25
- @markers = map.markers.permitted_to(@current_profile).order_by(ordering: :asc)
26
- # case map.ordering_type
27
- # when ::Gameui::Map::ORDERING_TYPE_ALPHABETIC
28
- # @markers = @markers.order_by( name: :asc )
29
- # when ::Gameui::Map::ORDERING_TYPE_CUSTOM
30
- # @markers = @markers.order_by( ordering: :asc )
31
- # end
32
-
33
- if map.is_premium && !@current_profile.has_premium_purchase( map )
34
- render 'show_restricted'
35
- else
36
- respond_to do |format|
37
- format.json do
38
- render 'show'
39
- end
40
- format.html do
41
- render 'show'
42
- end
43
- end
44
- end
45
- end
46
-
47
- def show_marker
48
- @marker = ::Gameui::Marker.find_by slug: params[:slug]
49
- authorize! :show, @marker
50
- render json: @marker
51
- end
52
-
53
- end
54
-
@@ -1,45 +0,0 @@
1
-
2
- require_dependency "ishapi/application_controller"
3
-
4
- ##
5
- ## @deprecated, use Ishapi::LocationsController
6
- ##
7
- class Ishapi::MapsController < Ishapi::ApplicationController
8
- before_action :check_profile, only: [ :show ]
9
-
10
- def show
11
- if 'self' == params[:slug] # @TODO: constantize _vp_ 2023-01-11
12
- @location = ::Gameui::Map.where( slug: @current_profile[:email] ).first
13
- else
14
- @location = ::Gameui::Map.where( slug: params[:slug] ).first
15
- @location ||= ::Gameui::Map.find params[:slug]
16
- end
17
- @map = @location.map || @location
18
-
19
- authorize! :show, @map
20
-
21
- @newsitems = @location.newsitems.page( params[:newsitems_page] ).per( @location.newsitems_page_size )
22
-
23
- @markers = @map.markers.permitted_to(@current_profile).order_by(ordering: :asc)
24
- # case @map.ordering_type
25
- # when ::Gameui::Map::ORDERING_TYPE_ALPHABETIC
26
- # @markers = @markers.order_by( name: :asc )
27
- # when ::Gameui::Map::ORDERING_TYPE_CUSTOM
28
- # @markers = @markers.order_by( ordering: :asc )
29
- # end
30
-
31
- if @map.is_premium && !@current_profile.has_premium_purchase( @map )
32
- render 'show_restricted'
33
- else
34
- render 'show'
35
- end
36
- end
37
-
38
- def show_marker
39
- @marker = ::Gameui::Marker.find_by slug: params[:slug]
40
- authorize! :show, @marker
41
- render json: @marker
42
- end
43
-
44
- end
45
-
@@ -1,11 +0,0 @@
1
-
2
- class Ishapi::My::GalleriesController < Ishapi::ApplicationController
3
-
4
- def index
5
- authorize! :my_index, Gallery
6
- @galleries = @current_user.profile.galleries.unscoped.where( is_trash: false ).order_by( created_at: :desc ).limit(20)
7
- render 'ishapi/galleries/index'
8
- end
9
-
10
- end
11
-
@@ -1,11 +0,0 @@
1
-
2
-
3
- class Ishapi::My::ReportsController < Ishapi::ApplicationController
4
-
5
- def index
6
- authorize! :my_index, Report
7
- @reports = @profile.reports
8
- end
9
-
10
- end
11
-
@@ -1,10 +0,0 @@
1
-
2
- class Ishapi::My::VideosController < Ishapi::ApplicationController
3
-
4
- def index
5
- authorize! :my_index, Video
6
- @videos = @current_user.profile.videos.unscoped.where( is_trash: false ).order_by( created_at: :desc ).limit(20)
7
- end
8
-
9
- end
10
-
@@ -1,35 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
-
3
- module Ishapi
4
- class NewsitemsController < ApplicationController
5
-
6
- before_action :check_profile
7
-
8
- def destroy
9
- n = Newsitem.find params[:id]
10
-
11
- puts! n.map.creator_profile.id, 'ze id'
12
- puts! current_user.profile.id, 'ze2 id'
13
-
14
- authorize! :destroy, n
15
- flag = n.destroy
16
- if flag
17
- render json: { status: 'ok' }, status: :ok
18
- else
19
- render json: { message: "No luck: #{n.errors.full_messages.join(", ")}." }, status: 400
20
- end
21
- end
22
-
23
- def index
24
- if params[:domain]
25
- resource = Site.find_by( :domain => params[:domain], :lang => :en )
26
- else
27
- resource = current_user.profile
28
- end
29
-
30
- authorize! :show, resource
31
- @newsitems = current_user.profile.newsitems
32
- end
33
-
34
- end
35
- end
@@ -1,27 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
-
3
- module Ishapi
4
- class ObfuscatedRedirectsController < ApplicationController
5
-
6
- def show
7
- @obf = Office::ObfuscatedRedirect.find params[:id]
8
- puts! @obf, '@obf'
9
- authorize! :show, @obf
10
-
11
- visit_time = Time.now
12
- @obf.update_attributes({
13
- visited_at: visit_time,
14
- visits: @obf.visits + [ visit_time ],
15
- })
16
-
17
- if DEBUG
18
- render and return
19
- end
20
-
21
- redirect_to @obf.to
22
-
23
- end
24
-
25
- end
26
- end
27
-
@@ -1,44 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
-
3
- module Ishapi
4
- class OptionPriceItemsController < ApplicationController
5
-
6
- # before_action :soft_check_long_term_token, only: [ :show ]
7
- # before_action :check_jwt
8
-
9
- ## params: symbol, begin_at, end_at
10
- def view
11
- authorize! :view_chain, ::Iro::OptionPriceItem
12
- @opis = ::Iro::OptionPriceItem.where({ ticker: params[:symbol]
13
- }).where( "timestamp BETWEEN ? and ? ", params[:begin_at], params[:end_at]
14
- ).limit(100)
15
- end
16
-
17
- def view_by_symbol
18
- authorize! :view_chain, ::Iro::OptionPriceItem
19
- @opis = ::Iro::OptionPriceItem.where({ symbol: params[:symbol]
20
- }).limit(100)
21
- render 'view'
22
- end
23
-
24
- # kind-1, always
25
- def index
26
- authorize! :view_chain, ::Iro::OptionPriceItem
27
- @opis = Iro::OptionPriceItem.where({
28
- expirationDate: '1676062800000',
29
- timestamp: '2023-02-06 14:46:48',
30
- })
31
- @outs = {}
32
- @opis.map do |opi|
33
- r = @outs[opi.strikePrice] || {}
34
- r[opi.putCall] = ((opi.bid + opi.ask)/2).round(3)
35
- @outs[opi.strikePrice] = r
36
- end
37
- render json: @outs
38
- return
39
- end
40
-
41
- end
42
- end
43
-
44
-
@@ -1,53 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
-
3
- module Ishapi
4
- class OrderItemsController < ApplicationController
5
- before_action :check_profile, :only => [ :create ]
6
-
7
- def create
8
- authorize! :add, CoTailors::OrderItem
9
- @order_item = CoTailors::OrderItem.new params['order_item'].permit( :quantity, :kind, :fabric )
10
- @order_item.order_id = @current_order.id
11
- @order_item.measurement = @measurement
12
- @order_item.cost = case params[:order_item][:kind]
13
- when CoTailors::OrderItem::KIND_SHIRT
14
- CoTailors::Product.where( :kind => 'shirt' ).first.cost
15
- when CoTailors::OrderItem::KIND_PANTS
16
- CoTailors::Product.where( :kind => 'pants' ).first.cost
17
- when CoTailors::OrderItem::KIND_SUIT
18
- CoTailors::Product.where( :kind => 'suit' ).first.cost
19
- end
20
- @order_item.measurement = CoTailors::ProfileMeasurement.create params['order_item'].permit( CoTailors::Order::MEASUREMENT_PARAMS )
21
-
22
- # byebug
23
-
24
- if params[:order_item][:saveMeasurement]
25
- m = @current_profile.measurement || CoTailors::ProfileMeasurement.create( :profile => @current_profile )
26
- flag = m.update_attributes( measurement_params )
27
- if !flag
28
- render :json => { :statuc => :not_ok, :error => m.errors.messages }
29
- return
30
- end
31
- end
32
-
33
- flag = @order_item.save
34
- if flag
35
- render :json => { :status => :ok, :message => 'Successfully put an order item' }
36
- else
37
- render :json => { :status => :not_ok, :error => @order_item.errors.messages }
38
- end
39
- end
40
-
41
- #
42
- # private
43
- #
44
- private
45
-
46
- def measurement_params
47
- out = {}
48
- out[:neck_around] = params[:order_item][:neckAround] if params[:order_item][:neckAround]
49
- out
50
- end
51
-
52
- end
53
- end
@@ -1,32 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
-
3
- module Ishapi
4
- class OrdersController < ApplicationController
5
- before_action :check_profile, :only => [ :create ]
6
-
7
- def create
8
- authorize! :create, CoTailors::Order
9
-
10
- # params = {"token"=>{"id"=>"tok_1BoLkRDpn3WurCccVNQK4pfV", "object"=>"token", "card"=>{"id"=>"card_1BoLkRDpn3WurCccET5cyAMU", "object"=>"card", "address_city"=>nil, "address_country"=>nil, "address_line1"=>nil, "address_line1_check"=>nil, "address_line2"=>nil, "address_state"=>nil, "address_zip"=>"42424", "address_zip_check"=>"unchecked", "brand"=>"Visa", "country"=>"US", "cvc_check"=>"unchecked", "dynamic_last4"=>nil, "exp_month"=>4, "exp_year"=>2024, "funding"=>"credit", "last4"=>"4242", "metadata"=>{}, "name"=>nil, "tokenization_method"=>nil}, "client_ip"=>"76.103.54.198", "created"=>1516929079, "livemode"=>false, "type"=>"card", "used"=>false}, "accessToken"=>"EAAcgM1d2EyABAFAvisZBJy0vnlmunq1RM5rbcfUN0B1G6WGwulGkwqfJyP8Ue8Gb1DsyHyjLZCmEmMKKjhZCFF8JIyyZAGLLyqpIr8kg6wWhAIzLQ7HbYfmwFI8aZARtJB4ZBo4KZBbBx4wHUmLoPqAsG2Ca2DXKPkZD", "order"=>{"token"=>{"id"=>"tok_1BoLkRDpn3WurCccVNQK4pfV", "object"=>"token", "card"=>{"id"=>"card_1BoLkRDpn3WurCccET5cyAMU", "object"=>"card", "address_city"=>nil, "address_country"=>nil, "address_line1"=>nil, "address_line1_check"=>nil, "address_line2"=>nil, "address_state"=>nil, "address_zip"=>"42424", "address_zip_check"=>"unchecked", "brand"=>"Visa", "country"=>"US", "cvc_check"=>"unchecked", "dynamic_last4"=>nil, "exp_month"=>4, "exp_year"=>2024, "funding"=>"credit", "last4"=>"4242", "metadata"=>{}, "name"=>nil, "tokenization_method"=>nil}, "client_ip"=>"76.103.54.198", "created"=>1516929079, "livemode"=>false, "type"=>"card", "used"=>false}, "accessToken"=>"EAAcgM1d2EyABAFAvisZBJy0vnlmunq1RM5rbcfUN0B1G6WGwulGkwqfJyP8Ue8Gb1DsyHyjLZCmEmMKKjhZCFF8JIyyZAGLLyqpIr8kg6wWhAIzLQ7HbYfmwFI8aZARtJB4ZBo4KZBbBx4wHUmLoPqAsG2Ca2DXKPkZD"}}
11
-
12
- @order = CoTailors::Order.where( :profile_id => @current_profile.id, :submitted_at => nil ).first
13
- @order.submitted_at = Time.now
14
-
15
- Stripe.api_key = STRIPE_SK
16
- charge = Stripe::Charge.create :amount => @order.grand_total, :currency => 'usd', :source => params['token']['id']
17
- flag = charge.outcome[:type] == 'authorized'
18
- if !flag
19
- render :json => { :status => :not_ok, :message => "Something went wrong with the charge: " + charge.outcome.to_s }
20
- return
21
- end
22
-
23
- flag = @order.save
24
- if flag
25
- render :json => { :status => :ok, :message => 'Successfully placed the order' }
26
- else
27
- render :json => { :status => :not_ok, :error => @order.errors.messages }
28
- end
29
- end
30
-
31
- end
32
- end
@@ -1,108 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
- class Ishapi::PaymentsController < ::Ishapi::ApplicationController
3
-
4
- before_action :check_profile, only: %i| create unlock |
5
-
6
- protect_from_forgery with: :exception
7
- skip_before_action :verify_authenticity_token, only: %i| stripe_confirm |
8
-
9
- # alphabetized : )
10
-
11
- ## _vp_ 2020-07-21 This is for guyd
12
- ## _vp_ 2022-03-01 It's been a while!
13
- ## _vp_ 2022-09-04 continue
14
- ## _vp_ 2023-03-29 Continue
15
- ##
16
- ## @TODO: cannot proceed if already is_purchasing?
17
- ## @TODO: and this doesn't say what you're buying! herehere
18
- ##
19
- def create
20
- authorize! :create, Ish::Payment.new
21
-
22
- @current_profile.update_attributes({ is_purchasing: true })
23
-
24
- amount_cents = params[:amount_cents].to_i # @TODO: change
25
-
26
- ::Stripe.api_key = ::STRIPE_SK
27
- intent = Stripe::PaymentIntent.create({
28
- amount: amount_cents,
29
- currency: 'usd',
30
- metadata: { integration_check: "accept_a_payment" },
31
- })
32
-
33
- item_type = case params[:item_type]
34
- when 'Ish::Location'
35
- 'Gameui::Map'
36
- else
37
- throw "item_type not implemented: #{params[:item_type]}"
38
- end
39
- item = item_type.constantize.find params[:item_id]
40
-
41
- payment = Ish::Payment.create!(
42
- client_secret: intent.client_secret,
43
- email: @current_profile.email,
44
- item: item,
45
- payment_intent_id: intent.id,
46
- profile_id: @current_profile.id,
47
- )
48
- render json: {
49
- client_secret: intent.client_secret,
50
- clientSecret: intent.client_secret,
51
- }
52
-
53
- end
54
-
55
- ##
56
- ## webhook
57
- ## _vp_ 2023-03-29 Continue
58
- ##
59
- def stripe_confirm
60
- authorize! :open_permission, ::Ishapi
61
- payload = request.body.read
62
- event = nil
63
- begin
64
- event = Stripe::Event.construct_from(JSON.parse(payload, symbolize_names: true))
65
- rescue StandardError => err
66
- puts! err, 'could not #stripe_confirm'
67
- render status: 400, json: { status: :not_ok }
68
- return
69
- end
70
-
71
- payment_intent = event.data.object
72
- puts! payment_intent, 'payment_intent'
73
-
74
- payment = Ish::Payment.where( payment_intent_id: payment_intent.id ).first
75
- if payment && payment_intent['status'] == 'succeeded'
76
-
77
- payment.update_attributes( status: Ish::Payment::STATUS_CONFIRMED )
78
- n_unlocks = payment.profile.n_unlocks + 1 # @TODO: it's not always 5, adjust! herehere
79
-
80
- payment.profile.update_attributes!( n_unlocks: n_unlocks, is_purchasing: false )
81
- end
82
-
83
- render status: 200, json: { status: :ok }
84
- end
85
-
86
- ##
87
- ## Spend an unlock without spending money. _vp_ 2022-03-01
88
- ##
89
- def unlock
90
- authorize! :unlock, ::Ish::Payment
91
- item = Object::const_get(params['kind']).find params['id']
92
-
93
- existing = Ish::Payment.where( profile: @current_profile, item: item ).first
94
- if existing
95
- render status: 200, json: { status: :ok, message: 'already purchased' }
96
- return
97
- end
98
-
99
- @current_profile.inc( n_unlocks: -item.premium_tier )
100
-
101
- purchase = ::Ish::Payment.create!( item: item, profile: @current_profile, )
102
-
103
- @profile = @current_profile
104
- render 'ishapi/user_profiles/account'
105
- end
106
-
107
- end
108
-
@@ -1,13 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
-
3
- class Ishapi::PhotosController < Ishapi::ApplicationController
4
-
5
- # before_action :soft_check_long_term_token, only: [ :show ]
6
- before_action :check_jwt
7
-
8
- def show
9
- @photo = Photo.find params[:id]
10
- authorize! :show, @photo
11
- end
12
-
13
- end
@@ -1,16 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
-
3
- class Ishapi::ProductsController < Ishapi::ApplicationController
4
-
5
- # before_action :soft_check_long_term_token, only: [ :show ]
6
- before_action :check_jwt
7
-
8
- def show
9
- @product = Wco::Product.find params[:id]
10
-
11
- puts! @product.prices.to_a, 'to_a'
12
-
13
- authorize! :show, @product
14
- end
15
-
16
- end
@@ -1,13 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
- module Ishapi
3
- class StockWatchesController < ApplicationController
4
-
5
- before_action :check_jwt
6
-
7
- def index
8
- # authorize! :index, IronWarbler::StockWatch
9
- # @stock_watches = IronWarbler::StockWatch.active # @TODO: restrict by-profile, no?
10
- end
11
-
12
- end
13
- end
@@ -1,27 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
- module Ishapi
3
- class UserProfilesController < ApplicationController
4
-
5
- before_action :check_profile, only: %i| show | ## @TODO: hmmm I may not need this check at all
6
-
7
- before_action :check_profile_hard, only: %i| update |
8
-
9
- def show
10
- @profile = Ish::UserProfile.find_by :username => params[:username]
11
- authorize! :show, @profile
12
- end
13
-
14
- def update
15
- @profile = Ish::UserProfile.find @current_user.profile
16
- authorize! :update, @profile
17
-
18
- flag = @profile.update params[:profile].permit!
19
- if flag
20
- render json: { message: 'ok' }, status: :ok
21
- else
22
- render json: { message: "No luck: #{@profile.errors.full_messages.join(", ")}." }, code: 400
23
- end
24
- end
25
-
26
- end
27
- end