Class: Fae::NetlifyApi

Inherits:
Object
  • Object
show all
Defined in:
app/services/fae/netlify_api.rb

Instance Method Summary collapse

Constructor Details

#initializeNetlifyApi

Returns a new instance of NetlifyApi.



6
7
8
9
10
11
12
13
# File 'app/services/fae/netlify_api.rb', line 6

def initialize()
  @netlify_api_user   = Fae.netlify[:api_user]
  @netlify_api_token  = Fae.netlify[:api_token]
  @site               = Fae.netlify[:site]
  @site_id            = Fae.netlify[:site_id]
  @endpoint_base      = Fae.netlify[:api_base]
  @logger             = Logger.new(Rails.root.join('log', 'netlify_api.log'))
end

Instance Method Details

#get_deploysObject



15
16
17
18
# File 'app/services/fae/netlify_api.rb', line 15

def get_deploys
  path = "sites/#{@site_id}/deploys?per_page=15"
  get_deploys_env_response(path)
end

#run_deploy(deploy_hook_type, current_user) ⇒ Object



20
21
22
23
24
25
26
27
# File 'app/services/fae/netlify_api.rb', line 20

def run_deploy(deploy_hook_type, current_user)
  hook = Fae::DeployHook.find_by_environment(deploy_hook_type)
  if hook.present?
    post("#{hook.url}?trigger_title=#{current_user.full_name.gsub(' ', '+')}+triggered+a+#{deploy_hook_type.titleize}+deploy")
    return true
  end
  false
end