Skip to content

Instantly share code, notes, and snippets.

class Customers::ExternalCustomerFinder
class CustomerNotFound < StandardError; end
attr_reader :params, :customer
def initialize(params, replace_old_contact: false, create_new_customer: true)
@params = params || {}
@replace_old_contact = replace_old_contact
@create_new_customer = create_new_customer
end
@hewrin
hewrin / haravan_activate_charge_service.rb
Created June 16, 2020 07:58
Refactoring actiavate charge service for 360 - also trying out only changing variables in def call method
class Haravan::ActivateChargeService
def initialize(shop:, params:)
@params = params
@shop = shop
@plan = Plan.find_by(id: params[:plan_id])
end
def call
@hewrin
hewrin / recurring_charges_controller.rb
Created June 16, 2020 03:05
Recurring Charges controller
# frozen_string_literal: true
class Api::V1::RecurringChargesController < Api::V1::BaseController
before_action :set_ecommerce_api_session
def create
plan = Plan.find_by(id: params[:plan_id])
if current_shop.ecom_provider == 'Haravan'
service = Haravan::RecurringApplicationChargeService.new(plan: plan, shop: current_shop)
@hewrin
hewrin / haravan_recurring_application_charge_service.rb
Created June 16, 2020 02:52
Haravan service object for recurring_application_charge_service
class Haravan::RecurringApplicationChargeService
attr_reader :render_hash
def initialize(plan:, shop:)
@plan = plan
@shop = shop
@redirect_url = ''
@session = nil
end
@hewrin
hewrin / shopify_recurring_application_charge_service.rb
Last active June 16, 2020 02:52
Shopify service object for recurring_application_charge_service
class Shopify::RecurringApplicationChargeService
attr_reader :render_hash
def initialize(shop:)
@shop = shop
@shop_country = @shop.address.country
@render_hash = {}
end
def call
@hewrin
hewrin / articleTable.js
Created June 8, 2020 04:55
I'm trying to create an Editable Table, But for some reason the `values` value is empty even though I have set initialValues.
import React, { useEffect, useState, useCallback } from "react"
import "@shopify/polaris/styles.css";
import { AppProvider, Card, ResourceList, ResourceItem, TextField, FormLayout, Filters, Page } from '@shopify/polaris';
import ApolloClient from 'apollo-boost';
import { gql } from "apollo-boost";
import { Formik, Form, Field, FieldArray } from 'formik';
function ArticleTable ({token}) {
const [queryValue, setQueryValue] = useState(null);
const [blogPostList, setblogPostList] = useState([]);
@hewrin
hewrin / svg-convert.sh
Created November 8, 2018 07:31 — forked from zolthan/svg-convert.sh
Convert SVG to PNG @2x @3x
#!/bin/bash
# I made this script to convert SVG icons for an iOS app into PNG.
# The script will create icons in 3 sizes for different screen DPIs.
find . -type f -name "*.svg" | while read f
do
echo '---'
FILENAME="${f%.*}"
echo $FILENAME
import { call, put, select } from 'redux-saga/effects';
import Config from 'react-native-config';
import { SHOW_SUCCESS_SCREEN, SHOW_ERROR_SCREEN } from '../../actions/statusScreen';
const bulkParcelUpdate = params => fetch(`${Config.SERVER_URL}/api/v2/agents/parcels`, {
method: 'PATCH',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${params.authToken}`,
export const SHOW_ERROR_SCREEN = 'SHOW_ERROR_SCREEN'
export const SHOW_ERROR_SCREEN_WITH_CUSTOM_MESSAGE = 'SHOW_ERROR_SCREEN_WITH_CUSTOM_MESSAGE'
export const HIDE_ERROR_SCREEN = 'HIDE_ERROR_SCREEN'
export const SHOW_SUCCESS_SCREEN = 'SHOW_SUCCESS_SCREEN'
const showErrorScreen = () => (
{ type: SHOW_ERROR_SCREEN }
)
import { SHOW_ERROR_SCREEN, SHOW_ERROR_SCREEN_WITH_CUSTOM_MESSAGE, HIDE_ERROR_SCREEN, SHOW_SUCCESS_SCREEN } from '../actions/statusScreen';
const initialState = {
show: false,
errorTitle: '',
errorMessage: '',
success: false
};