Slide 1

Slide 1 text

Hyperdrive API Client in Swift

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Traditionally

Slide 4

Slide 4 text

"Move fast and break things" Mark Zuckerberg, Facebook

Slide 5

Slide 5 text

"Each version will remain for at least 2 years from release." Facebook

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

Move Fast, Break Nothing

Slide 9

Slide 9 text

Designing API by exposing implementation details

Slide 10

Slide 10 text

API Evolvability

Slide 11

Slide 11 text

Ability to change implementation details

Slide 12

Slide 12 text

Learn about controls, relations and transitions at run-time

Slide 13

Slide 13 text

Adding new features

Slide 14

Slide 14 text

Remove features

Slide 15

Slide 15 text

Ability to change implementation details 4 Change fields used in forms 4 Change validation of attributes in forms 4 Change URIs of resources (/polls/{id} -> / questions/{slug}) 4 Change HTTP methods (PUT -> PATCH) 4 Change the content-type

Slide 16

Slide 16 text

Teach Clients Semantic meaning of the Domain

Slide 17

Slide 17 text

Don’t hard-code implementation details

Slide 18

Slide 18 text

Hyperdrive

Slide 19

Slide 19 text

hyperdrive(apiary: "pollsapi")

Slide 20

Slide 20 text

hyperdrive(blueprint: "https://polls.apiblueprint.org/")

Slide 21

Slide 21 text

hyperdrive(apiary: "pollsapi") { result in // Explore API feature availability }

Slide 22

Slide 22 text

hyperdrive.enter("https://polls.apiblueprint.org/") { result in // Explore API feature availability }

Slide 23

Slide 23 text

Representor

Slide 24

Slide 24 text

if let questions = representor.links["questions"] { // The API offered us a link to questions } else { // Gracefully handle when this feature is missing }

Slide 25

Slide 25 text

hyperdrive.request(questions) { result in }

Slide 26

Slide 26 text

representor.links

Slide 27

Slide 27 text

representor.transitions

Slide 28

Slide 28 text

if let create = representor.transitions["create"] { // API supports creation } else { // Feature is missing // Let's not show the create button in our UI }

Slide 29

Slide 29 text

let attributes = [ "question": "Favourite language?", "choices": [ "Swift", "Ruby", "Python", ] ] hyperdrive.request(create, attributes) { }

Slide 30

Slide 30 text

create.attributes

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

create.validate(["email": "kyle"]) ❌

Slide 33

Slide 33 text

create.validate(["email": "[email protected]"]) ✅

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

Change our API

Slide 37

Slide 37 text

Demo

Slide 38

Slide 38 text

Hyperdrive

Slide 39

Slide 39 text

Hyperdrive β

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

kyle fuller kyle @ apiary.io