Module: Moip::Header

Included in:
Customer, Invoice, Payment, Plan, Subscription
Defined in:
lib/moip/header.rb

Instance Method Summary collapse

Instance Method Details

#authObject



12
13
14
# File 'lib/moip/header.rb', line 12

def auth
	@auth ||= {:username => Moip.config.token, :password => Moip.config.acount_key}
end

#base_url(model, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/moip/header.rb', line 16

def base_url model, options = {}
	url = ""

	if Moip.config.env == "production"
		url = "https://api.moip.com.br/assinaturas/v1/#{model.to_s}"
	else
		url = "https://sandbox.moip.com.br/assinaturas/v1/#{model.to_s}" 
	end
		
	url << "/#{options[:code]}" 	if options[:code]
	url << "/#{options[:status]}" if options[:status]
	url << "?#{options[:params]}" if options[:params]
	url
end

#default_header(json = nil) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/moip/header.rb', line 3

def default_header json = nil
	header = {}
	header.merge! :basic_auth => auth
	header.merge! :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
	header.merge! :body => json if json

	header
end