Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Building API clients with Cistern
Search
Adam Holt
February 20, 2014
Programming
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Building API clients with Cistern
@nwrug - github.com/lanej/cistern
Adam Holt
February 20, 2014
More Decks by Adam Holt
See All by Adam Holt
NWRUG - Celluloid
omgitsads
3
250
Other Decks in Programming
See All in Programming
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
160
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
270
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
130
Embedded Swiftで作る自作USBデバイス によるiOSデバイスの自動テスト / iOSDC Japan 2026 glassfiber
glassfiber
0
260
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
0
320
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
180
速習iPhone Duo対応
yuukiw00w
2
930
The Rails Doctrine Decade
koic
2
460
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
290
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
1
2.1k
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
120
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Featured
See All Featured
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
510
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
710
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
The Cost Of JavaScript in 2023
addyosmani
55
10k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
320
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.9k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
390
How to train your dragon (web standard)
notwaldorf
97
6.8k
Statistics for Hackers
jakevdp
799
230k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.7k
Transcript
BUILDING API CLIENTS WITH CISTERN
@adamholt
@lanejoshlane
WHAT IS CISTERN?
“Cistern helps you consistently build your API clients and facilitates
building mock support.”
None
SERVICE
class Twitter::Client < Cistern::Service ! model_path "twitter/models" request_path "twitter/requests" !
model :tweet collection :tweets request :create_tweet ! class Real def initialize(options={}) # Setup end end ! class Mock def self.data; @data ||= {}; end ! def initialize(options={}) # Setup Mock Data end end end
class Twitter::Client < Cistern::Service model_path "twitter/models" request_path "twitter/requests" ! ...
end
class Twitter::Client < Cistern::Service ... ! model :tweet collection :tweets
request :create_tweet ! ... end
class Twitter::Client < Cistern::Service ... ! class Real def initialize(options={})
# Setup end end ! class Mock def self.data; @data ||= {}; end ! def initialize(options={}) # Setup Mock Data end end end
MODELS
class Twitter::Client::Tweet < Cistern::Model identity :id ! attribute :user, type:
:hash attribute :tweet, type: :array ! def retweet requires :id ! new_attributes = connection.retweet_tweet(id: id).body merge_attributes(new_attributes) end end !
COLLECTIONS
class Twitter::Client::Tweets < Cistern::Collection ! model Twitter::Client::Tweet ! def timeline(params
= {}) response = connection.get_tweets(params) ! data = self.clone.load(response.body) ! collection.attributes.clear collection.merge_attributes(data) end ! def retweets(params={}) response = connection.get_retweets(params) ... end ! def get(id) new(connection.get_tweet("id" => id).body) end end
REQUESTS
module Twitter class Client class Real def create_tweet(options={}) request( :body
=> {status: options[:body]}, :method => :post, :path => '/statuses/update' ) end end # Real ! ... end # Client end # Twitter
module Twitter class Client ... ! class Mock def create_tweet(options={})
id = Foo.random_hex(6) ! tweet = { "id" => id, "text" => "Hello from @NWRUG", "user" => {"name": "omgitsads"}, }.merge(options) ! self.data[:tweets][id]= tweet ! response( :body => tweet, :status => 200, :path => '/statuses/user_timeline.json', ) end end # Mock end # Client end # Twitter
DRAWBACKS
QUESTIONS?