Service exposing API that aggregates over third party Social Networking APIs such as Facebook and Twitter. Though as a demo the interactions with these third parties are stubbed.
SBT/Scala setup. Firstly you will need homebrew:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Install JDK (Java)
- Install sbt (Scala)
$ brew install homebrew/cask/java
$ brew cask info java
$ brew install sbt
$ brew info sbt
To "get the code" we need git.
$ brew install git
And then clone this repository:
$ git clone https://github.com/davidainslie/social.git
Finally, for manually testing install httpie, though you can of course use curl but it's not as nice:
$ brew install httpie
Test
$ sbt test
Run
$ sbt run
However run in this case expects to interact with actual third party (backend) APIs, so instead we can run with stubs:
$ sbt test:run
Story:
Given a social network name Facebook
And a full Facebook graph
Return count of people with no relationships
From the command line:
$ http http://localhost:8080/relationships/facebook
HTTP/1.1 200 OK
Content-Length: 9
Content-Type: application/json
Date: Mon, 16 Dec 2019 09:59:33 GMT
[
"Harry"
]
Story:
Given a person name Peter
And a Facebook graph for Peter
And a Twitter graph for Peter
Return count of relationships of 1 degree + count of relationships of 2 degree
From the command line:
http http://localhost:8080/relationships/Peter
HTTP/1.1 200 OK
Content-Length: 44
Content-Type: application/json
Date: Mon, 16 Dec 2019 11:48:58 GMT
{
"firstDegreeCount": 3,
"secondDegreeCount": 0
}