Skip to content

Instantly share code, notes, and snippets.

View nateklaiber's full-sized avatar

Nate Klaiber nateklaiber

View GitHub Profile

API

Here are the concerns:

  • Routes: How do I get to the necessary resource?
  • Configuration: What options do I want for my connection or requests
  • Connection: How do I connect to the application? Typically this will be HTTP(S).
  • Logging: We will have specific logging for the api, the requests, and applications.
  • Errors: We will have specific exceptions we raise if any issues arise.
  • Requests: These use the routes and connections to make a request to the service. The return from this is a response.
  • Response: The response from a request is typically a schema that aligns with content negotiation (Content-Type or Accept)
@nateklaiber
nateklaiber / _overview.md
Last active March 8, 2024 15:53
Pizza Service SDK Architecture

SDK Architecture

Rough Draft

This is still in rough draft form. I will continue to make edits as I receive them. I will collate the list of feedback here and make notes of the changelog as revisions are made.

What does it solve?

String Interpolation

No string interpolation for building your routes to your resources.

Keybase proof

I hereby claim:

  • I am nateklaiber on github.
  • I am nateklaiber (https://keybase.io/nateklaiber) on keybase.
  • I have a public key whose fingerprint is 6930 A573 358D 135A 2269 F9CC 7B5D D6D8 F811 B831

To claim this, I am signing this object:

class FlatArray
instance_methods.each do |m|
undef_method(m) unless m =~ /(^__|^nil\?|^send$|^object_id$)/
end
def initialize(array)
@target = array
end
def respond_to?(symbol, include_priv=false)
@nateklaiber
nateklaiber / design.md
Last active April 24, 2024 18:11
API Client Design
t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time
cat *.json |\
jq 'map(select(.from.name=="Nate Klaiber"))' |\
jq '.[].message' |\
grep -v 'jq' |\
sed -e 's/\([[:punct:]]\)//g' |\
grep -v '^$' |\
tr '\n' ' ' |\
tr ' ' '\n' |\
tr '[:upper:]' '[:lower:]' |\
sort |\
@nateklaiber
nateklaiber / .env.sample
Last active August 29, 2015 14:13
Dover Utilities Electric Usage Information
API_HOST='http://utilities.theklaibers.com'
CACHE_HOST='localhost:11211'
@nateklaiber
nateklaiber / envelope_expansion_example.md
Last active August 29, 2015 14:01
Envelope Expansion Example

I'll use Stripe as an example. The client is responsible for:

  • Configuration
  • Routing
  • Connection Handling
  • Request Handling
    • Raw requests with JSON
    • Object model requests that wrap the raw request (allow us to say Stripe::Request::Charge.get(id: 'sdfsdf'))
  • Object Creation. This includes top level and associations.
@nateklaiber
nateklaiber / relation_expansion.md
Created May 27, 2014 15:15
API Relation Expansion

Given an object has an owner association (relation), when expanded by default it will be exposed as:

{
  "name": "service-production",
  "owner": {
    "id": "5d8201b0...",
    "name": "Alice",
    "email": "alice@heroku.com"
 },