Class: PagSeguro::Url

Inherits:
Object
  • Object
show all
Defined in:
lib/pag_seguro/url.rb

Constant Summary collapse

InvalidEnvironmentError =
Class.new(StandardError)

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.environmentObject

Returns the value of attribute environment.



4
5
6
# File 'lib/pag_seguro/url.rb', line 4

def environment
  @environment
end

Class Method Details

.api_url(path) ⇒ Object



27
28
29
# File 'lib/pag_seguro/url.rb', line 27

def self.api_url(path)
  File.join(root_uri(:api), path)
end

.root_uri(type) ⇒ Object



22
23
24
25
# File 'lib/pag_seguro/url.rb', line 22

def self.root_uri(type)
  root = uris.fetch(environment.to_sym) { raise InvalidEnvironmentError }
  root[type.to_sym]
end

.site_url(path) ⇒ Object



31
32
33
# File 'lib/pag_seguro/url.rb', line 31

def self.site_url(path)
  File.join(root_uri(:site), path)
end

.urisObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pag_seguro/url.rb', line 9

def self.uris
  @uris ||= {
    production: {
      api: "https://ws.pagseguro.uol.com.br/v2",
      site: "https://pagseguro.uol.com.br/v2"
    },
    sandbox: {
      api: "https://ws.sandbox.pagseguro.uol.com.br/v2",
      site: "https://sandbox.pagseguro.uol.com.br/v2"
    }
  }
end