Module: SnapCiManualTrigger

Defined in:
lib/snap_ci_manual_trigger.rb,
lib/snap_ci_manual_trigger/service.rb,
lib/snap_ci_manual_trigger/version.rb

Defined Under Namespace

Classes: InvalidCredentialsError, InvalidResourceError, Service

Constant Summary collapse

DEFAULT_BRANCH_NAME =
'master'.freeze
VERSION =
'0.1.0'

Class Method Summary collapse

Class Method Details

.for(user:, api_key:, owner:, repository:, branch_name: DEFAULT_BRANCH_NAME, connection: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/snap_ci_manual_trigger.rb', line 14

def self.for(user:, api_key:, owner:, repository:, branch_name: DEFAULT_BRANCH_NAME, connection: nil)
  raise InvalidCredentialsError, 'it needs both user and api_key' unless user.present? && api_key.present?
  raise InvalidResourceError, 'it needs an owner' unless owner.present?
  raise InvalidResourceError, 'it needs an repository' unless repository.present?

  Service.new user: user,
              api_key: api_key,
              owner: owner,
              repository: repository,
              branch_name: branch_name,
              connection: connection
end