Skip to content

Instantly share code, notes, and snippets.

View cored's full-sized avatar
🐽
Hacking Everything

Rafael George cored

🐽
Hacking Everything
View GitHub Profile
# == Schema Information
#
# Table name: shipments
#
# id :integer not null, primary key
# number :string(255)
# order_number :string(255)
# shipping_address_id :integer
# status :string(255)
# tracking :string(255)
@doc """
Parses
## Examples
iex>params_string = "name=Baloo&type=Brown"
iex>Servy.Parser.parse_params("application/x-www-form-urlencoded",
%{"name" => "Baloo", "type" => "Brown"})
iex>Servy.Parser.parse_params("multipart/form-data", params_string, %{})
"""
def parse_params("application/x-www-form-urlencoded", params_string) do
require "rails_helper"
describe ServiceOptionsSlot do
include_context "supports soft delete"
end
def create(conv, %{"name" => name, "type" => type} = _params) do
%{ conv | status: 201,
resp_body: "Created a #{type} bear named #{name}" }
end
@cored
cored / parse.ex
Last active February 13, 2018 23:41
def parse_headers(header_lines) do
Enum.reduce(header_lines, %{}, fn(line, headers) ->
[key, value] = String.split(line, ":")
Map.put(headers, key, value)
end)
end
require "dry-struct"
require_relative "../../../../../app/services/inventory/flexe/types"
require_relative "../../../../../app/services/inventory/flexe/deliveries/container_delivery_details"
describe Inventory::Flexe::Deliveries::ContainerDeliveryDetails do
let(:container_delivery_details_attrs) do
{
shipment_id: "1",
shipment_type: "container_delivery",
reservation_id: "34543",
defmodule Recurse do
def sum([head | tail], accu) do
sum(tail, accu + head)
end
def sum([], accu), do: accu
end
IO.puts "Total: #{Recurse.sum([1,2,3,4,5], 0)}"
# == Schema Information
#
# Table name: shipment_errors
#
# id :integer not null, primary key
# shipment_id :integer
# handled_by_id :integer
# message :text
# created_at :datetime
# deleted_at :datetime
defmodule Servy.Conv do
alias Servy.Conv
defstruct method: "", path: "", resp_body: "", status: nil
def full_status(%Conv{} = conv) do
"#{conv.status} #{status_reason(conv.status)}"
end
defp status_reason(code) do
module Fulfillment
module BulkShipments
module Types
include Dry::Types.module
end
class PalletLabels < Dry::Struct
HEADER_PADDING = 20
constructor_type :strict_with_defaults