class Reposync::UpdateRepoAddrService < Reposync::ClientService

  attr_accessor :repo_name, :internal_repo_address, :inter_token, :external_repo_address, :exter_token

  def initialize(repo_name, internal_repo_address, inter_token, external_repo_address, exter_token)
    @repo_name = repo_name
    @internal_repo_address = internal_repo_address
    @inter_token = inter_token
    @external_repo_address = external_repo_address
    @exter_token = exter_token
  end

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

  private
  def request_params
    Hash.new.merge(data: {
      internal_repo_address: internal_repo_address,
      inter_token: inter_token,
      external_repo_address: external_repo_address,
      exter_token: exter_token
    }.stringify_keys)
  end

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