Skip to content

Commit

Permalink
feat(providers): Implement ability to specify header or body key for …
Browse files Browse the repository at this point in the history
…token/event type
  • Loading branch information
viction committed Dec 6, 2020
1 parent aafe84d commit f0aa9fa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/main/scala/venix/hookla/providers/BaseProvider.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package venix.hookla.providers

trait BaseProvider {
def id: String
def name: String
def logo: String
def eventHeader: Option[String]
def tokenHeader: Option[String]

def eventHeader: Option[String] = None
def tokenHeader: Option[String] = None
def eventBodyKey: Option[String] = None
def tokenBodyKey: Option[String] = None


def events: List[Nothing] // What type innit
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ package venix.hookla.providers.gitlab

import venix.hookla.providers.BaseProvider

class Provider extends BaseProvider {
class GitlabProvider extends BaseProvider {
def id = "gitlab"
def name = "Gitlab"
def logo = "https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/GitLab_Logo.svg/1108px-GitLab_Logo.svg.png"

def events = List()
override def eventHeader = Some("X-Gitlab-Event")
override def tokenHeader = Some("X-Gitlab-Token")

def events = Nil
}
13 changes: 13 additions & 0 deletions src/main/scala/venix/hookla/services/ProviderService.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package venix.hookla.services

import javax.inject.Inject
import venix.hookla.providers.BaseProvider
import venix.hookla.providers.gitlab.GitlabProvider

class ProviderService @Inject()(
gitlabProvider: GitlabProvider
) {
private def providers: List[BaseProvider] = gitlabProvider :: Nil

def getById(id: String): Option[BaseProvider] = providers.find(p => p.id == id)
}

0 comments on commit f0aa9fa

Please sign in to comment.