source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | somleng/somleng | https://github.com/somleng/somleng | app/models/tariff_package_plan.rb | Ruby | mit | 95 | develop | 265 | class TariffPackagePlan < ApplicationRecord
extend Enumerize
belongs_to :package, class_name: "TariffPackage"
belongs_to :plan, class_name: "TariffPlan"
enumerize :category, in: TariffSchedule.category.values, value_class: TariffScheduleCategoryValue
end |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/user.rb | Ruby | mit | 95 | develop | 2,333 | class User < ApplicationRecord
extend Enumerize
EMAIL_FORMAT = /\A[^@\s]+@[^@\s]+\z/
enumerize :carrier_role, in: %i[owner admin member], predicates: true
enumerize :subscribed_notification_topics,
in: [
"error_logs.inbound_message",
"error_logs.inbound_call",
... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/date_range.rb | Ruby | mit | 95 | develop | 425 | class DateRange
attr_reader :from_date, :to_date
def initialize(from_date:, to_date:)
@from_date = from_date
@to_date = to_date
end
def to_range
Range.new(from_date, to_date && (to_date + 1.day))
end
def valid?
return false if empty?
return true if to_date.blank? || from_date.blank?
... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/carrier_standing.rb | Ruby | mit | 95 | develop | 668 | class CarrierStanding
MAX_TRIAL_INTERACTIONS_PER_MONTH = 100
attr_reader :carrier
def initialize(carrier)
@carrier = carrier
end
def good_standing?
return true unless carrier.restricted?
remaining_interactions.positive?
end
def remaining_interactions
[ interactions_limit - interaction... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/api_authorization_request.rb | Ruby | mit | 95 | develop | 683 | class APIAuthorizationRequest
attr_reader :request
def self.call(request)
new(request).validate
end
def initialize(request)
@request = request
end
def validate
authorization_token
end
private
def authorization_token
Doorkeeper::OAuth::Token.from_request(
request,
:from... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/outbound_calls_queue.rb | Ruby | mit | 95 | develop | 627 | class OutboundCallsQueue < UniqueFIFOQueue
attr_reader :account
def initialize(account, **)
super(key: "account:#{account.id}:outbound_calls", **)
@account = account
end
class << self
def each_queue(&)
AppSettings.redis.with do |connection|
queues = connection.scan_each(match: "*acco... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/price_formatter.rb | Ruby | mit | 95 | develop | 555 | class PriceFormatter
attr_reader :formatter
def initialize(formatter: ActiveSupport::NumberHelper)
@formatter = formatter
end
def format(value, with_currency: false)
return if value.blank?
with_currency ? format_with_currency(value) : format_without_currency(value)
end
private
def format_... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/incoming_phone_number.rb | Ruby | mit | 95 | develop | 905 | class IncomingPhoneNumber < ApplicationRecord
extend Enumerize
belongs_to :carrier
belongs_to :phone_number_plan
belongs_to :account
belongs_to :phone_number, optional: true
belongs_to :messaging_service, optional: true
has_many :phone_calls
has_many :messages
enumerize :voice_method, in: %w[POST G... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/verification_delivery_attempt.rb | Ruby | mit | 95 | develop | 469 | class VerificationDeliveryAttempt < ApplicationRecord
extend Enumerize
enumerize :channel, in: Verification.channel.values, predicates: true
belongs_to :verification, counter_cache: :delivery_attempts_count
belongs_to :message, optional: true
belongs_to :phone_call, optional: true
belongs_to :phone_number... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/account_billing_policy.rb | Ruby | mit | 95 | develop | 912 | class AccountBillingPolicy
attr_reader :credit_validator, :tariff_calculator, :error_code
def initialize(**options)
@credit_validator = options.fetch(:credit_validator) { RatingEngineClient.new }
@tariff_calculator = options.fetch(:tariff_calculator) { TariffCalculator.new }
end
def valid?(interaction... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/account.rb | Ruby | mit | 95 | develop | 1,771 | class Account < ApplicationRecord
self.inheritance_column = :_type_disabled
extend Enumerize
enumerize :type, in: [ :carrier_managed, :customer_managed ], predicates: true, scope: :shallow
enumerize :status, in: %i[enabled disabled], predicates: true, default: :enabled
enumerize :billing_mode, in: [ :prepai... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/url_validator.rb | Ruby | mit | 95 | develop | 935 | class URLValidator
attr_reader :options
BAD_HOSTS = [ "localhost" ].freeze
def initialize(options = {})
@options = options
end
def valid?(value)
return true if value.blank? && options[:allow_blank]
return false unless format.match?(value)
uri = URI.parse(value)
return false if BAD_HOST... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/aggregate_data.rb | Ruby | mit | 95 | develop | 544 | class AggregateData
class IDGenerator
def generate_id(key)
Digest::SHA256.hexdigest(key.reject(&:blank?).map(&:downcase).join(":"))
end
end
attr_reader :key, :groups, :value, :sequence_number, :id_generator
def initialize(**options)
@key = options.fetch(:key)
@groups = options.fetch(:gro... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/phone_number.rb | Ruby | mit | 95 | develop | 2,522 | class PhoneNumber < ApplicationRecord
self.inheritance_column = :_type_disabled
extend Enumerize
NUMBER_FORMAT = /\A\d+\z/
E164_TYPES = [ :local, :mobile, :toll_free ].freeze
NON_164_TYPES = [ :short_code ].freeze
TYPES = (NON_164_TYPES + E164_TYPES).uniq.freeze
enumerize :type, in: TYPES
enumerize :... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/infinite_precision_money.rb | Ruby | mit | 95 | develop | 684 | class InfinitePrecisionMoney < Money
self.default_infinite_precision = true
class Formatter < Money::Formatter
private
def format_decimal_part(value)
return nil if currency.decimal_places == 0 && !money.class.default_infinite_precision
return nil if rules[:no_cents]
return nil if rules[:... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/carrier.rb | Ruby | mit | 95 | develop | 2,148 | class Carrier < ApplicationRecord
has_many :accounts
has_many :managed_accounts, -> { carrier_managed }, class_name: "Account"
has_many :account_memberships, through: :accounts
has_many :account_users, through: :accounts, source: :users, class_name: "User"
has_many :carrier_users, -> { carrier }, class_name: ... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/media_stream.rb | Ruby | mit | 95 | develop | 797 | class MediaStream < ApplicationRecord
include AASM
extend Enumerize
enumerize :tracks, in: %i[inbound outbound both]
belongs_to :account
belongs_to :phone_call
has_many :events, class_name: "MediaStreamEvent"
aasm column: :status, whiny_transitions: false do
state :initialized, initial: true
st... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/tariff_plan.rb | Ruby | mit | 95 | develop | 687 | class TariffPlan < ApplicationRecord
extend Enumerize
belongs_to :carrier
has_many :tiers, class_name: "TariffPlanTier", foreign_key: :plan_id
has_many :schedules, through: :tiers, class_name: "TariffSchedule"
has_many :destination_tariffs, through: :schedules
has_many :destination_groups, through: :destin... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/phone_number_formatter.rb | Ruby | mit | 95 | develop | 353 | class PhoneNumberFormatter
attr_reader :formatter
def initialize(formatter: Phony)
@formatter = formatter
end
def format(value, options = {})
return value if value.blank?
return value.to_s unless value.e164?
if options[:format] == :e164
"+#{value}"
else
formatter.format(value.... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/verification_service.rb | Ruby | mit | 95 | develop | 605 | class VerificationService < ApplicationRecord
MAX_NAME_LENGTH = 30
VALID_CODE_LENGTHS = (4..10)
DEFAULT_CODE_LENGTH = 6
belongs_to :carrier
belongs_to :account
has_many :verifications
validates :code_length,
presence: true,
numericality: {
only_integer: true,
... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/inbound_source_ip_address.rb | Ruby | mit | 95 | develop | 671 | class InboundSourceIPAddress < ApplicationRecord
has_many :sip_trunk_inbound_source_ip_addresses
validates :ip, :region, presence: true
attribute :region, RegionType.new
attribute :call_service_client, default: -> { CallService::Client.new }
after_create :add_permission
after_destroy :remove_permission
... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/destination_tariff.rb | Ruby | mit | 95 | develop | 229 | class DestinationTariff < ApplicationRecord
belongs_to :schedule, class_name: "TariffSchedule"
belongs_to :destination_group
belongs_to :tariff, dependent: :destroy, autosave: true
has_many :plans, through: :schedule
end |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/verification_attempt.rb | Ruby | mit | 95 | develop | 232 | class VerificationAttempt < ApplicationRecord
belongs_to :verification, counter_cache: true
encrypts :code
def successful?
ActiveSupport::SecurityUtils.secure_compare(
code,
verification.code
)
end
end |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/event.rb | Ruby | mit | 95 | develop | 519 | class Event < ApplicationRecord
self.inheritance_column = :_type_disabled
extend Enumerize
TYPES = %i[
phone_call.completed
message.sent
message.delivered
].freeze
belongs_to :carrier
belongs_to :phone_call, optional: true
belongs_to :message, optional: true
has_many :webhook_request_log... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/destination_rules.rb | Ruby | mit | 95 | develop | 1,317 | class DestinationRules
attr_reader :account, :destination
def initialize(account:, destination:)
@account = account
@destination = destination
end
def valid?
calling_code_allowed? && sip_trunk.present?
end
def calling_code_allowed?
return true if account.allowed_calling_codes.empty?
... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/phone_call.rb | Ruby | mit | 95 | develop | 3,442 | class PhoneCall < ApplicationRecord
extend Enumerize
include AASM
before_create :set_beneficiary_data
attribute :beneficiary_fingerprint, SHA256Type.new
attribute :to, PhoneNumberType.new
attribute :from, PhoneNumberType.new
attribute :region, RegionType.new
enumerize :voice_method, in: %w[POST GET]
... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/smart_encoding.rb | Ruby | mit | 95 | develop | 13,775 | class SmartEncoding
CHARACTERS = {
"\u00ab" => '"', # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
"\u00bb" => '"', # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
"\u201c" => '"', # LEFT DOUBLE QUOTATION MARK
"\u201d" => '"', # RIGHT DOUBLE QUOTATION MARK
"\u02ba" => '"', # MODIFIER LETTER DOUBLE PRIME... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/routing_parameters.rb | Ruby | mit | 95 | develop | 582 | class RoutingParameters
attr_reader :phone_call
def initialize(phone_call)
@phone_call = phone_call
end
def to_h
{
address: phone_call.to.sip_address,
destination: phone_call.to.to_s,
dial_string_prefix: sip_trunk.outbound_dial_string_prefix,
plus_prefix: sip_trunk.outbound_plu... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/inbound_message_behavior.rb | Ruby | mit | 95 | develop | 1,018 | class InboundMessageBehavior
attr_reader :incoming_phone_number
delegate :messaging_service, to: :incoming_phone_number, allow_nil: true, private: true
delegate :inbound_message_behavior, to: :messaging_service, allow_nil: true, private: true
delegate :webhook?, :drop?,
to: :inbound_message_behavior... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/rate_limiter.rb | Ruby | mit | 95 | develop | 2,065 | class RateLimiter
class RateLimitExceededError < StandardError
attr_reader :seconds_remaining_in_current_window
def initialize(message, seconds_remaining_in_current_window:)
super(message)
@seconds_remaining_in_current_window = seconds_remaining_in_current_window
end
end
class TimeWindow... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/exponential_backoff.rb | Ruby | mit | 95 | develop | 464 | class ExponentialBackoff
JITTER_DEFAULT = 0.15
attr_reader :random_number_generator
def initialize(options = {})
@random_number_generator = options.fetch(:random_number_generator, -> { Kernel.rand })
end
# https://github.com/rails/rails/blob/83217025a171593547d1268651b446d3533e2019/activejob/lib/active... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/phone_number_configuration_rules.rb | Ruby | mit | 95 | develop | 345 | class PhoneNumberConfigurationRules
attr_reader :error_message
def valid?(incoming_phone_number)
if incoming_phone_number.blank?
@error_message = "Phone number %<value>s does not exist."
elsif block_given? && !yield
@error_message = "Phone number %<value>s is unconfigured."
end
@error_... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/account_membership.rb | Ruby | mit | 95 | develop | 259 | class AccountMembership < ApplicationRecord
extend Enumerize
belongs_to :account, counter_cache: true
belongs_to :user
enumerize :role, in: %i[owner admin member], predicates: true, scope: :shallow
delegate :otp_required_for_login, to: :user
end |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/recording.rb | Ruby | mit | 95 | develop | 409 | class Recording < ApplicationRecord
extend Enumerize
include AASM
has_one_attached :file
has_one_attached :mp3_file
belongs_to :phone_call
belongs_to :account
enumerize :status_callback_method, in: %w[POST GET]
aasm column: :status do
state :in_progress, initial: true
state :completed
e... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/tariff_calculator.rb | Ruby | mit | 95 | develop | 413 | class TariffCalculator
def calculate(tariff_plan:, destination:)
return if destination.blank?
DestinationTariff
.joins(:plans)
.joins(destination_group: :prefixes)
.where(plans: { id: tariff_plan.id })
.where("? LIKE destination_prefixes.prefix || '%'", destination)
.order("LENG... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/unique_fifo_queue.rb | Ruby | mit | 95 | develop | 3,011 | class UniqueFIFOQueue
ENQUEUE_SCRIPT = <<~LUA
if redis.call("zscore", KEYS[1], ARGV[2]) then return 0 end
if redis.call("zscore", KEYS[2], ARGV[2]) then return 0 end
redis.call("zadd", KEYS[1], ARGV[1], ARGV[2])
return 1
LUA
DEQUEUE_SCRIPT = <<~LUA
local members = redis.call("zrange", KEYS[1]... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/documentation_renderer.rb | Ruby | mit | 95 | develop | 1,083 | class DocumentationRenderer
attr_reader :template, :carrier
def initialize(template:, carrier:)
@template = template
@carrier = carrier
end
def render
set_logo
set_carrier_name
set_api_host
content
end
private
def set_logo
return unless carrier.logo.attached?
html_doc... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/call_session_limiter.rb | Ruby | mit | 95 | develop | 1,132 | class CallSessionLimiter
attr_reader :session_counters
def initialize(**options)
@session_counters = options.fetch(:session_counters) do
SomlengRegion::Region.all.each_with_object({}) do |region, result|
result[region.alias.to_sym] = SimpleCounter.new(
key: options.fetch(:key) { "#{opti... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/sip_trunk_inbound_source_ip_address.rb | Ruby | mit | 95 | develop | 602 | class SIPTrunkInboundSourceIPAddress < ApplicationRecord
belongs_to :sip_trunk
belongs_to :carrier
belongs_to :inbound_source_ip_address
attribute :region, RegionType.new
validates :ip, :region, presence: true
before_validation :set_carrier, :find_or_initialize_inbound_source_ip_address
private
def... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/tariff_schedule.rb | Ruby | mit | 95 | develop | 563 | class TariffSchedule < ApplicationRecord
extend Enumerize
belongs_to :carrier
has_many :destination_tariffs, foreign_key: :schedule_id, dependent: :destroy
has_many :destination_groups, through: :destination_tariffs
has_many :plan_tiers, class_name: "TariffPlanTier", foreign_key: :schedule_id, dependent: :re... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/interaction.rb | Ruby | mit | 95 | develop | 381 | class Interaction < ApplicationRecord
extend Enumerize
enumerize :interactable_type, in: %w[Message PhoneCall]
belongs_to :account
belongs_to :carrier
belongs_to :phone_call, optional: true
belongs_to :message, optional: true
attribute :beneficiary_fingerprint, SHA256Type.new
def beneficiary_country
... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/tariff_package.rb | Ruby | mit | 95 | develop | 315 | class TariffPackage < ApplicationRecord
belongs_to :carrier
has_many :account_billing_profiles
has_many :accounts, through: :account_billing_profiles
has_many :package_plans, class_name: "TariffPackagePlan", foreign_key: :package_id
has_many :plans, through: :package_plans, class_name: "TariffPlan"
end |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/sms_gateway_channel_group.rb | Ruby | mit | 95 | develop | 240 | class SMSGatewayChannelGroup < ApplicationRecord
belongs_to :sms_gateway
has_many :channels, class_name: "SMSGatewayChannel", foreign_key: :channel_group_id
def configured_channel_slots
channels.pluck(:slot_index).sort
end
end |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/concerns/decoratable_resource.rb | Ruby | mit | 95 | develop | 331 | module DecoratableResource
extend ActiveSupport::Concern
included do
delegate :decorator_class, to: :class
end
def decorated
return self if decorator_class.blank?
decorator_class.new(self)
end
module ClassMethods
def decorator_class
"#{model_name}Decorator".safe_constantize
end... |
github | somleng/somleng | https://github.com/somleng/somleng | app/models/concerns/serializable_resource.rb | Ruby | mit | 95 | develop | 359 | module SerializableResource
extend ActiveSupport::Concern
included do
delegate :jsonapi_serializer_class, to: :class
end
module ClassMethods
def jsonapi_serializer_class
"CarrierAPI::#{model_name}Serializer".constantize
end
def csv_serializer_class
"CSVSerializer::#{model_name}Ser... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/home_dashboard.rb | Ruby | mit | 95 | develop | 688 | require "administrate/custom_dashboard"
class HomeDashboard < Administrate::CustomDashboard
def self.resource_name(_opts)
"Home"
end
def current_call_sessions
per_region { GlobalCallSessionLimiter.new.session_count_for(_1) }
end
def call_service_capacity
per_region { CallServiceCapacity.current... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/tariff_dashboard.rb | Ruby | mit | 95 | develop | 620 | require "administrate/base_dashboard"
class TariffDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
carrier: Field::BelongsTo,
category: Field::String,
currency: Field::String,
rate_cents: Field::String,
created_at: Field::LocalTime,
updated_at: Field::LocalTi... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/recording_dashboard.rb | Ruby | mit | 95 | develop | 746 | require "administrate/base_dashboard"
class RecordingDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
phone_call: Field::BelongsTo,
id: Field::String,
external_id: Field::String,
status: Field::String,
status_callback_url: Field::String,
status_callback_method: Field::String,
f... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/phone_call_event_dashboard.rb | Ruby | mit | 95 | develop | 555 | require "administrate/base_dashboard"
class PhoneCallEventDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
phone_call: Field::BelongsTo,
id: Field::String,
params: Field::JSON.with_options(searchable: false),
type: Field::String,
created_at: Field::LocalTime,
updated_at: Field::Loc... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/sip_trunk_dashboard.rb | Ruby | mit | 95 | develop | 1,107 | require "administrate/base_dashboard"
class SIPTrunkDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
carrier: Field::BelongsTo,
default_sender: Field::String,
id: Field::String,
name: Field::String,
region: Field::String,
max_channels: Field::String,
inbound_country_code: Field... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/tariff_schedule_dashboard.rb | Ruby | mit | 95 | develop | 713 | require "administrate/base_dashboard"
class TariffScheduleDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
carrier: Field::BelongsTo,
category: Field::String,
name: Field::String,
description: Field::Text,
created_at: Field::LocalTime,
updated_at: Field::Loca... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/phone_number_plan_dashboard.rb | Ruby | mit | 95 | develop | 832 | require "administrate/base_dashboard"
class PhoneNumberPlanDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
phone_number: Field::BelongsTo,
incoming_phone_number: Field::HasOne,
carrier: Field::BelongsTo,
account: Field::BelongsTo,
id: Field::String,
number: Field::String,
amou... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/export_dashboard.rb | Ruby | mit | 95 | develop | 750 | require "administrate/base_dashboard"
class ExportDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
user: Field::BelongsTo,
filter_params: Field::JSON.with_options(searchable: false),
scoped_to: Field::JSON.with_options(searchable: false),
name: Field::String,
sta... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/phone_call_dashboard.rb | Ruby | mit | 95 | develop | 2,539 | require "administrate/base_dashboard"
class PhoneCallDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
account: Field::BelongsTo,
sip_trunk: Field::BelongsTo,
balance_transaction: Field::HasOne,
call_data_record: Field::BelongsTo,
phone_call_events: Field::HasMany,
media_streams: Fi... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/tariff_package_dashboard.rb | Ruby | mit | 95 | develop | 599 | require "administrate/base_dashboard"
class TariffPackageDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
carrier: Field::BelongsTo,
package_plans: Field::HasMany,
name: Field::String,
description: Field::Text,
created_at: Field::LocalTime,
updated_at: Field:... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/sms_gateway_dashboard.rb | Ruby | mit | 95 | develop | 751 | require "administrate/base_dashboard"
class SMSGatewayDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
carrier: Field::BelongsTo,
default_sender: Field::String,
channel_groups: Field::HasMany,
name: Field::String,
max_channels: Field::String,
last_connected_a... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/statistic_dashboard.rb | Ruby | mit | 95 | develop | 4,148 | require "administrate/custom_dashboard"
class StatisticDashboard < Administrate::CustomDashboard
resource "Statistics"
class Filter
TIME_FORMATS = {
day: "%d %B %Y",
month: "%B %Y",
year: "%Y"
}.freeze
attr_reader :name, :reference_time, :time_period, :column
def initialize(nam... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/phone_number_dashboard.rb | Ruby | mit | 95 | develop | 1,062 | require "administrate/base_dashboard"
class PhoneNumberDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
carrier: Field::BelongsTo,
active_plan: Field::HasOne,
plans: Field::HasMany,
phone_calls: Field::HasMany,
messages: Field::HasMany,
id: Field::String,
number: Field::String,... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/verification_service_dashboard.rb | Ruby | mit | 95 | develop | 702 | require "administrate/base_dashboard"
class VerificationServiceDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
carrier: Field::BelongsTo,
account: Field::BelongsTo,
verifications: Field::HasMany,
name: Field::String,
code_length: Field::Number,
created_at: F... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/tariff_plan_subscription_dashboard.rb | Ruby | mit | 95 | develop | 566 | require "administrate/base_dashboard"
class TariffPlanSubscriptionDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
account: Field::BelongsTo,
category: Field::String,
plan: Field::BelongsTo,
created_at: Field::LocalTime,
updated_at: Field::LocalTime
}.freeze
... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/error_log_dashboard.rb | Ruby | mit | 95 | develop | 650 | require "administrate/base_dashboard"
class ErrorLogDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
carrier: Field::BelongsTo,
account: Field::BelongsTo,
notifications: Field::HasMany,
id: Field::String,
error_message: Field::String,
type: Field::String,
created_at: Field::Loc... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/account_membership_dashboard.rb | Ruby | mit | 95 | develop | 436 | require "administrate/base_dashboard"
class AccountMembershipDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
user: Field::BelongsTo,
account: Field::BelongsTo,
role: Field::String
}.freeze
COLLECTION_ATTRIBUTES = %i[
id
user
account
role
].freeze
... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/carrier_dashboard.rb | Ruby | mit | 95 | develop | 1,558 | require "administrate/base_dashboard"
class CarrierDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
accounts: Field::HasMany,
sip_trunks: Field::HasMany,
phone_numbers: Field::HasMany,
phone_calls: Field::HasMany.with_options(sort_by: :sequence_number, direction: :desc),
messages: Fiel... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/media_stream_dashboard.rb | Ruby | mit | 95 | develop | 681 | require "administrate/base_dashboard"
class MediaStreamDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
phone_call: Field::BelongsTo,
account: Field::BelongsTo,
events: Field::HasMany,
url: Field::String,
status: Field::String,
tracks: Field::String,
cust... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/error_log_notification_dashboard.rb | Ruby | mit | 95 | develop | 520 | require "administrate/base_dashboard"
class ErrorLogNotificationDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
error_log: Field::BelongsTo,
user: Field::BelongsTo,
email: Field::String,
created_at: Field::LocalTime,
updated_at: Field::LocalTime
}.freeze
CO... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/sms_gateway_channel_group_dashboard.rb | Ruby | mit | 95 | develop | 659 | require "administrate/base_dashboard"
class SMSGatewayChannelGroupDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
sms_gateway: Field::BelongsTo,
name: Field::String,
route_prefixes: Field::String,
configured_channel_slots: Field::String,
created_at: Field::Local... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/call_data_record_dashboard.rb | Ruby | mit | 95 | develop | 1,043 | require "administrate/base_dashboard"
class CallDataRecordDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
phone_call: Field::BelongsTo,
id: Field::String,
external_id: Field::String,
file: Field::ActiveStorage.with_options(export: false),
bill_sec: Field::Number,
duration_sec: Fie... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/verification_dashboard.rb | Ruby | mit | 95 | develop | 1,131 | require "administrate/base_dashboard"
class VerificationDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
verification_service: Field::BelongsTo,
carrier: Field::BelongsTo,
account: Field::BelongsTo,
to: Field::String,
channel: Field::String,
status: Field::St... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/tariff_plan_dashboard.rb | Ruby | mit | 95 | develop | 873 | require "administrate/base_dashboard"
class TariffPlanDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
carrier: Field::BelongsTo,
category: Field::String,
name: Field::String,
description: Field::Text,
created_at: Field::LocalTime,
updated_at: Field::LocalTim... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/tts_event_dashboard.rb | Ruby | mit | 95 | develop | 630 | require "administrate/base_dashboard"
class TTSEventDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
carrier: Field::BelongsTo,
account: Field::BelongsTo,
phone_call: Field::BelongsTo,
tts_voice: Field::String,
num_chars: Field::Number,
created_at: Field::Loc... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/incoming_phone_number_dashboard.rb | Ruby | mit | 95 | develop | 1,353 | require "administrate/base_dashboard"
class IncomingPhoneNumberDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
carrier: Field::BelongsTo,
phone_number_plan: Field::BelongsTo,
account: Field::BelongsTo,
phone_number: Field::BelongsTo,
messaging_service: Field::BelongsTo,
phone_call... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/account_dashboard.rb | Ruby | mit | 95 | develop | 1,817 | require "administrate/base_dashboard"
class AccountDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
carrier: Field::BelongsTo,
sip_trunk: Field::BelongsTo,
id: Field::String,
type: Field::String,
name: Field::String,
default_tts_voice: Field::String,
created_at: Field::LocalTim... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/event_dashboard.rb | Ruby | mit | 95 | develop | 708 | require "administrate/base_dashboard"
class EventDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
carrier: Field::BelongsTo,
phone_call: Field::BelongsTo,
message: Field::BelongsTo,
type: Field::String,
details: Field::JSON,
webhook_request_logs: Field::HasMa... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/webhook_request_log_dashboard.rb | Ruby | mit | 95 | develop | 758 | require "administrate/base_dashboard"
class WebhookRequestLogDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
event: Field::BelongsTo,
carrier: Field::BelongsTo,
url: Field::String,
http_status_code: Field::String,
failed: Field::String,
payload: Field::JSON,... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/import_dashboard.rb | Ruby | mit | 95 | develop | 684 | require "administrate/base_dashboard"
class ImportDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
resource_type: Field::String,
status: Field::String,
error_message: Field::String,
user: Field::BelongsTo,
carrier: Field::BelongsTo,
created_at: Field::LocalTi... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/destination_tariff_dashboard.rb | Ruby | mit | 95 | develop | 585 | require "administrate/base_dashboard"
class DestinationTariffDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
destination_group: Field::BelongsTo,
schedule: Field::BelongsTo,
tariff: Field::BelongsTo,
created_at: Field::LocalTime,
updated_at: Field::LocalTime
}... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/tariff_plan_tier_dashboard.rb | Ruby | mit | 95 | develop | 555 | require "administrate/base_dashboard"
class TariffPlanTierDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
plan: Field::BelongsTo,
schedule: Field::BelongsTo,
weight: Field::Number,
created_at: Field::LocalTime,
updated_at: Field::LocalTime
}.freeze
COLLECTI... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/destination_group_dashboard.rb | Ruby | mit | 95 | develop | 715 | require "administrate/base_dashboard"
class DestinationGroupDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
carrier: Field::BelongsTo,
catch_all: Field::Boolean,
prefixes: Field::String.with_options(
getter: ->(field) {
field.resource.prefixes.pluck(:prefi... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/messaging_service_dashboard.rb | Ruby | mit | 95 | develop | 1,008 | require "administrate/base_dashboard"
class MessagingServiceDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
carrier: Field::BelongsTo,
account: Field::BelongsTo,
incoming_phone_numbers: Field::HasMany,
messages: Field::HasMany,
name: Field::String,
inbound_m... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/media_stream_event_dashboard.rb | Ruby | mit | 95 | develop | 504 | require "administrate/base_dashboard"
class MediaStreamEventDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
media_stream: Field::BelongsTo,
type: Field::String,
details: Field::JSON,
created_at: Field::LocalTime,
updated_at: Field::LocalTime
}.freeze
COLLEC... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/message_dashboard.rb | Ruby | mit | 95 | develop | 2,388 | require "administrate/base_dashboard"
class MessageDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
carrier: Field::BelongsTo,
account: Field::BelongsTo,
phone_number: Field::BelongsTo,
incoming_phone_number: Field::BelongsTo,
sms_gateway: Field::BelongsTo,
m... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/user_dashboard.rb | Ruby | mit | 95 | develop | 1,250 | require "administrate/base_dashboard"
class UserDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
email: Field::String,
name: Field::String,
carrier_role: Field::String,
carrier: Field::BelongsTo,
sign_in_count: Field::String,
last_sign_in_at: Field::LocalTime... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/balance_transaction_dashboard.rb | Ruby | mit | 95 | develop | 737 | require "administrate/base_dashboard"
class BalanceTransactionDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
carrier: Field::BelongsTo,
account: Field::BelongsTo,
created_by: Field::BelongsTo,
id: Field::String,
type: Field::String,
amount: Field::String,
currency: Field::Str... |
github | somleng/somleng | https://github.com/somleng/somleng | app/dashboards/tariff_package_plan_dashboard.rb | Ruby | mit | 95 | develop | 561 | require "administrate/base_dashboard"
class TariffPackagePlanDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::String,
package: Field::BelongsTo,
plan: Field::BelongsTo,
category: Field::String,
created_at: Field::LocalTime,
updated_at: Field::LocalTime
}.freeze
COLL... |
github | somleng/somleng | https://github.com/somleng/somleng | app/errors/application_error/errors.rb | Ruby | mit | 95 | develop | 4,357 | module ApplicationError
module Errors
Error = Struct.new(:message, :code, keyword_init: true)
ERRORS = {
validity_period_expired: Error.new(code: "S1001", message: "Validity period expired"),
sms_gateway_disconnected: Error.new(code: "S1002", message: "SMS Gateway disconnected"),
update_bef... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/application_controller.rb | Ruby | mit | 95 | develop | 304 | class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
helper_method :current_carrier
helper_method :app_request
private
def current_carrier
@current_carrier ||= app_request.find_carrier!
end
def app_request
AppRequest.new(request)
end
end |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/services_controller.rb | Ruby | mit | 95 | develop | 417 | class ServicesController < APIController
include ActionController::HttpAuthentication::Basic::ControllerMethods
http_basic_authenticate_with(
name: Rails.configuration.app_settings.fetch(:services_username),
password: Rails.configuration.app_settings.fetch(:services_password)
)
private
def respond_... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/dashboard_controller.rb | Ruby | mit | 95 | develop | 957 | class DashboardController < ApplicationController
self.responder = DashboardResponder
respond_to :html
include UserAuthorization
prepend_before_action :authenticate_user!
before_action :enforce_two_factor_authentication!
helper_method :filter_params
private
def enforce_two_factor_authentication!
... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/api_controller.rb | Ruby | mit | 95 | develop | 837 | class APIController < ActionController::API
self.responder = APIResponder
respond_to :json
private
def validate_request_schema(with:, **options, &_block)
schema_options = options.delete(:schema_options) || {}
input_params = options.delete(:input_params) || request.request_parameters
schema = with... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/carrier_api_controller.rb | Ruby | mit | 95 | develop | 614 | class CarrierAPIController < APIController
self.responder = JSONAPIResponder
before_action -> { doorkeeper_authorize!(:carrier_api) }
private
def validate_request_schema(with:, **options, &block)
schema_options = options.delete(:schema_options) || {}
schema_options[:carrier] = current_carrier
su... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/twilio_api_controller.rb | Ruby | mit | 95 | develop | 1,741 | class TwilioAPIController < APIController
include ActionController::HttpAuthentication::Basic::ControllerMethods
self.responder = TwilioAPI::Responder
before_action :doorkeeper_authorize!
before_action :authorize_account!
private
def authorize_account!
return deny_access! unless authenticate_with_ht... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/concerns/user_authorization.rb | Ruby | mit | 95 | develop | 1,934 | module UserAuthorization
extend ActiveSupport::Concern
include Pundit::Authorization
include Devise::Controllers::SignInOut
included do
helper_method :current_carrier
helper_method :current_account
helper_method :current_account_membership
helper_method :parent_scope
before_action :authori... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/concerns/captcha_helper.rb | Ruby | mit | 95 | develop | 458 | module CaptchaHelper
private
def verify_captcha(**options)
failure_block = options.delete(:on_failure) || -> { render(:new) }
return yield if verify_recaptcha(minimum_score: Rails.configuration.app_settings.fetch(:recaptcha_minimum_score, 0.7), **options)
return yield if verify_recaptcha(secret_key: Ra... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/admin/application_controller.rb | Ruby | mit | 95 | develop | 509 | module Admin
class ApplicationController < Administrate::ApplicationController
helper ApplicationHelper
http_basic_authenticate_with(
name: Rails.configuration.app_settings.fetch(:admin_username),
password: Rails.configuration.app_settings.fetch(:admin_password)
)
private
def defaul... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/carrier_api/v1/phone_calls_controller.rb | Ruby | mit | 95 | develop | 1,022 | module CarrierAPI
module V1
class PhoneCallsController < CarrierAPIController
def index
validate_request_schema(
with: PhoneCallFilterRequestSchema,
input_params: request.query_parameters,
**serializer_options
) do |permitted_params|
scope.where(permit... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/carrier_api/v1/tts_events_controller.rb | Ruby | mit | 95 | develop | 670 | module CarrierAPI
module V1
class TTSEventsController < CarrierAPIController
def index
validate_request_schema(
with: TTSEventFilterRequestSchema,
input_params: request.query_parameters,
**serializer_options
) do |permitted_params|
tts_events_scope.whe... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/carrier_api/v1/phone_numbers_controller.rb | Ruby | mit | 95 | develop | 1,261 | module CarrierAPI
module V1
class PhoneNumbersController < CarrierAPIController
def index
respond_with_resource(scope, serializer_options)
end
def create
validate_request_schema(
with: PhoneNumberRequestSchema, **serializer_options
) do |permitted_params|
... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/carrier_api/v1/accounts_controller.rb | Ruby | mit | 95 | develop | 1,379 | module CarrierAPI
module V1
class AccountsController < CarrierAPIController
def index
respond_with_resource(accounts_scope, serializer_options)
end
def create
validate_request_schema(
with: AccountRequestSchema, **serializer_options
) do |permitted_params|
... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/carrier_api/v1/messages_controller.rb | Ruby | mit | 95 | develop | 993 | module CarrierAPI
module V1
class MessagesController < CarrierAPIController
def index
validate_request_schema(
with: MessageFilterRequestSchema,
input_params: request.query_parameters,
**serializer_options
) do |permitted_params|
scope.where(permitted_... |
github | somleng/somleng | https://github.com/somleng/somleng | app/controllers/carrier_api/v1/events_controller.rb | Ruby | mit | 95 | develop | 462 | module CarrierAPI
module V1
class EventsController < CarrierAPIController
def index
respond_with_resource(events_scope, serializer_options)
end
def show
respond_with_resource(events_scope.find(params[:id]), serializer_options)
end
private
def events_scope
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.