class Reposync::CreateSyncBranchService < Reposync::ClientService

  attr_accessor :repo_name, :internal_branch_name, :external_branch_name, :enable

  def initialize(repo_name, internal_branch_name, external_branch_name, enable=true)
    @repo_name = repo_name
    @internal_branch_name = internal_branch_name
    @external_branch_name = external_branch_name
    @enable = enable
  end

  def call 
    result = post(url, request_params)
    response = render_response(result)
  end

  private
  def request_params
    Hash.new.merge(data: {
      internal_branch_name: internal_branch_name,
      external_branch_name: external_branch_name,
      enable: enable
    }.stringify_keys)
  end

  def url 
    "/cerobot/sync/#{repo_name}/branch".freeze
  end

end