This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for @coupon do |f| %> | |
<% if @coordinator.stripe_coupon %> | |
<%= @coordinator.stripe_coupon.id %> (<%= @coordinator.coupon_discount %>) | |
<% end %> | |
<%= f.text_field :stripe_id, placeholder: "#{ @coordinator.stripe_coupon ? 'Update Promo Code' : 'Promo Code'}", | |
value: "#{@coordinator.stripe_coupon ? @coordinator.stripe_coupon.id : nil }" %> | |
<%= f.submit "#{ @coordinator.stripe_coupon ? 'Update' : 'Save'}", class:'btn btn-info btn-block' %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stripe_coupon | |
customer = Stripe::Customer.retrieve(self.stripe_id) | |
if customer['discount'] == nil | |
false | |
else | |
coupons = customer['discount']['coupon'] | |
end | |
rescue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StripeWrapper | |
def retrieve_customer(user) | |
Stripe::Customer.retrieve(user.stripe_id) | |
end | |
# more Stripe API calls | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CouponService | |
def initialize(user) | |
@customer = StripeWrapper.new.retrieve_customer(user) | |
end | |
def stripe_coupon | |
@customer["discount"]["coupon"] unless @customer["discount"].nil? | |
rescue | |
false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for @coupon do |f| %> | |
<% if @coupon_service.stripe_coupon %> | |
<%= @coupon_service.stripe_coupon_id %> (<%= @coupon_service.discount %>) | |
<% end %> | |
<%= f.text_field :stripe_id, placeholder: "#{ @coupon_service.stripe_coupon ? 'Update Promo Code' : 'Promo Code'}", value: "#{@coupon_service.stripe_coupon ? @coupon_service.stripe_coupon_id : nil }", :required => true %> | |
<%= f.submit "#{ @coupon_service.stripe_coupon ? 'Update' : 'Save'}", class:'btn btn-info btn-block' %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TwilioWrapper | |
attr_accessor :message, :phone, :from | |
def initialize | |
boot_twilio | |
end | |
def send_sms | |
@client.messages.create( | |
from: ENV['TWILIO_NUMBER'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TwitterWrapper | |
attr_accessor :twitter_handle, :message | |
def initialize | |
boot_twitter | |
end | |
def tweet | |
@client.update("@#{twitter_handle} #{message}") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SendDemoWuphf | |
def initialize(demo_wuphf) | |
@demo_wuphf = demo_wuphf | |
end | |
def execute | |
send_email | |
send_text | |
send_tweet | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TwitterWrapper | |
attr_accessor :twitter_handle, :message, :client | |
def initialize(token=ENV['TWITTER_ACCESS_TOKEN'], secret=ENV['TWITTER_ACCESS_TOKEN_SECRET']) | |
boot_twitter(token, secret) | |
end | |
def tweet | |
@client.update("@#{twitter_handle} #{message}") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
# API Routes | |
namespace :api, defaults: { format: 'json' } do | |
namespace :v1 do | |
# Routes for authentication will go here | |
resources :recipients | |
resources :messages, only: [:create] | |
end | |
end | |
end |
OlderNewer