diff --git a/CHANGELOG.md b/CHANGELOG.md index e2457ce..52f01bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,5 @@ ## [UNRELEASED] -### Added - -### Changed - -### Deprecated - -### Removed - -### Fixed - -### Security +This gem has been renamed to billwerk and the pactas_itero gem release has been deprecated. ## [0.3.0] - 2017-09-04 ### Added diff --git a/Gemfile b/Gemfile index c56ce4c..24622cf 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in pactas_itero.gemspec +# Specify your gem's dependencies in billwerk.gemspec gemspec diff --git a/README.md b/README.md index d74d596..2c03af3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -[![Build Status](https://travis-ci.org/shipcloud/pactas_itero.svg)](https://travis-ci.org/shipcloud/pactas_itero) +[![Build Status](https://travis-ci.org/shipcloud/billwerk.svg)](https://travis-ci.org/shipcloud/billwerk) -# PactasItero +# Billwerk TODO: Write a gem description @@ -9,7 +9,7 @@ TODO: Write a gem description Add this line to your application's Gemfile: ```ruby -gem 'pactas_itero' +gem 'billwerk' ``` And then execute: @@ -18,7 +18,7 @@ And then execute: Or install it yourself as: - $ gem install pactas_itero + $ gem install billwerk ## Usage @@ -26,7 +26,7 @@ TODO: Write usage instructions here ## Contributing -1. Fork it ( https://github.com/[my-github-username]/pactas_itero/fork ) +1. Fork it ( https://github.com/[my-github-username]/billwerk/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) diff --git a/Rakefile b/Rakefile index 529af33..11c8b25 100644 --- a/Rakefile +++ b/Rakefile @@ -8,7 +8,7 @@ end task :console do require 'irb' require 'irb/completion' - require 'pactas_itero' + require 'billwerk' ARGV.clear IRB.start end diff --git a/pactas_itero.gemspec b/billwerk.gemspec similarity index 68% rename from pactas_itero.gemspec rename to billwerk.gemspec index d63ed58..5c775ea 100644 --- a/pactas_itero.gemspec +++ b/billwerk.gemspec @@ -1,19 +1,19 @@ # coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'pactas_itero/version' +require 'billwerk/version' Gem::Specification.new do |spec| - spec.name = 'pactas_itero' - spec.version = PactasItero::VERSION + spec.name = 'billwerk' + spec.version = Billwerk::VERSION spec.authors = ['Simon Fröhler'] spec.email = "simon@shipcloud.io" - spec.summary = %q{pactas_itero provides a client mapping for accessing - the Pactas Itero API.} - spec.description = %q{pactas_itero provides a client mapping for accessing - the Pactas Itero API, making it easy to post your data to, adn read your - data from your Pactas account.} - spec.homepage = 'https://github.com/webionate/pactas_itero' + spec.summary = %q{billwerk provides a client mapping for accessing + the Billwerk API.} + spec.description = %q{billwerk provides a client mapping for accessing + the Billwerk API, making it easy to post your data to, adn read your + data from your Billwerk account.} + spec.homepage = 'https://github.com/webionate/billwerk' spec.license = 'MIT' spec.files = Dir["lib/**/*.rb"] + Dir["bin/*"] diff --git a/lib/pactas_itero.rb b/lib/billwerk.rb similarity index 69% rename from lib/pactas_itero.rb rename to lib/billwerk.rb index 8153888..3ac560d 100644 --- a/lib/pactas_itero.rb +++ b/lib/billwerk.rb @@ -1,15 +1,15 @@ -require 'pactas_itero/client' -require 'pactas_itero/default' +require 'billwerk/client' +require 'billwerk/default' -module PactasItero +module Billwerk class << self - include PactasItero::Configurable + include Billwerk::Configurable # API client based on configured options {Configurable} # - # @return [PactasItero::Client] API wrapper + # @return [Billwerk::Client] API wrapper def client - PactasItero::Client.new(options) + Billwerk::Client.new(options) end def respond_to_missing?(method_name, include_private = false) @@ -28,4 +28,4 @@ def method_missing(method_name, *args, &block) end end -PactasItero.setup +Billwerk.setup diff --git a/lib/billwerk/api.rb b/lib/billwerk/api.rb new file mode 100644 index 0000000..c4a3685 --- /dev/null +++ b/lib/billwerk/api.rb @@ -0,0 +1,20 @@ +require 'billwerk/ext/hash/camelize_keys' +require 'billwerk/api/oauth' +require 'billwerk/api/rated_items' +require 'billwerk/api/customers' +require 'billwerk/api/contracts' +require 'billwerk/api/orders' +require 'billwerk/api/invoices' +require "billwerk/api/payment_transactions" + +module Billwerk + module Api + include Billwerk::Api::OAuth + include Billwerk::Api::RatedItems + include Billwerk::Api::Customers + include Billwerk::Api::Contracts + include Billwerk::Api::Orders + include Billwerk::Api::Invoices + include Billwerk::Api::PaymentTransactions + end +end diff --git a/lib/pactas_itero/api/contracts.rb b/lib/billwerk/api/contracts.rb similarity index 98% rename from lib/pactas_itero/api/contracts.rb rename to lib/billwerk/api/contracts.rb index 0fe8fde..212a779 100644 --- a/lib/pactas_itero/api/contracts.rb +++ b/lib/billwerk/api/contracts.rb @@ -1,4 +1,4 @@ -module PactasItero +module Billwerk module Api module Contracts def customer_contracts(customer_id, options = {}) diff --git a/lib/pactas_itero/api/customers.rb b/lib/billwerk/api/customers.rb similarity index 97% rename from lib/pactas_itero/api/customers.rb rename to lib/billwerk/api/customers.rb index 1c1f17d..fe31bf6 100644 --- a/lib/pactas_itero/api/customers.rb +++ b/lib/billwerk/api/customers.rb @@ -1,4 +1,4 @@ -module PactasItero +module Billwerk module Api module Customers def create_customer(options = {}) diff --git a/lib/pactas_itero/api/invoices.rb b/lib/billwerk/api/invoices.rb similarity index 96% rename from lib/pactas_itero/api/invoices.rb rename to lib/billwerk/api/invoices.rb index 2885a74..f33b5be 100644 --- a/lib/pactas_itero/api/invoices.rb +++ b/lib/billwerk/api/invoices.rb @@ -1,4 +1,4 @@ -module PactasItero +module Billwerk module Api module Invoices diff --git a/lib/pactas_itero/api/oauth.rb b/lib/billwerk/api/oauth.rb similarity index 92% rename from lib/pactas_itero/api/oauth.rb rename to lib/billwerk/api/oauth.rb index ff8e721..9c3d9b8 100644 --- a/lib/pactas_itero/api/oauth.rb +++ b/lib/billwerk/api/oauth.rb @@ -1,5 +1,5 @@ -module PactasItero +module Billwerk module Api module OAuth def token(options = {}) diff --git a/lib/pactas_itero/api/orders.rb b/lib/billwerk/api/orders.rb similarity index 95% rename from lib/pactas_itero/api/orders.rb rename to lib/billwerk/api/orders.rb index 58f4a99..e9318cb 100644 --- a/lib/pactas_itero/api/orders.rb +++ b/lib/billwerk/api/orders.rb @@ -1,4 +1,4 @@ -module PactasItero +module Billwerk module Api module Orders def create_order(options = {}) diff --git a/lib/pactas_itero/api/payment_transactions.rb b/lib/billwerk/api/payment_transactions.rb similarity index 92% rename from lib/pactas_itero/api/payment_transactions.rb rename to lib/billwerk/api/payment_transactions.rb index 9213094..d863b47 100644 --- a/lib/pactas_itero/api/payment_transactions.rb +++ b/lib/billwerk/api/payment_transactions.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module PactasItero +module Billwerk module Api module PaymentTransactions def payment_transaction(payment_transaction_id) diff --git a/lib/pactas_itero/api/rated_items.rb b/lib/billwerk/api/rated_items.rb similarity index 97% rename from lib/pactas_itero/api/rated_items.rb rename to lib/billwerk/api/rated_items.rb index 34feb83..c9f2686 100644 --- a/lib/pactas_itero/api/rated_items.rb +++ b/lib/billwerk/api/rated_items.rb @@ -1,4 +1,4 @@ -module PactasItero +module Billwerk module Api module RatedItems def create_rated_item(contract_id, quantity, description, price_per_unit, tax_policy_id, options = {}) diff --git a/lib/pactas_itero/client.rb b/lib/billwerk/client.rb similarity index 87% rename from lib/pactas_itero/client.rb rename to lib/billwerk/client.rb index 708a132..88578cb 100644 --- a/lib/pactas_itero/client.rb +++ b/lib/billwerk/client.rb @@ -1,18 +1,18 @@ require 'base64' require 'rash' -require 'pactas_itero/configurable' -require 'pactas_itero/api' +require 'billwerk/configurable' +require 'billwerk/api' -module PactasItero +module Billwerk class Client - include PactasItero::Configurable - include PactasItero::Api + include Billwerk::Configurable + include Billwerk::Api attr_accessor :bearer_token def initialize(options = {}) - PactasItero::Configurable.keys.each do |key| - instance_variable_set(:"@#{key}", options[key] || PactasItero.instance_variable_get(:"@#{key}")) + Billwerk::Configurable.keys.each do |key| + instance_variable_set(:"@#{key}", options[key] || Billwerk.instance_variable_get(:"@#{key}")) end end diff --git a/lib/pactas_itero/configurable.rb b/lib/billwerk/configurable.rb similarity index 72% rename from lib/pactas_itero/configurable.rb rename to lib/billwerk/configurable.rb index 5f2944d..f94b600 100644 --- a/lib/pactas_itero/configurable.rb +++ b/lib/billwerk/configurable.rb @@ -1,4 +1,4 @@ -module PactasItero +module Billwerk module Configurable attr_accessor :bearer_token, :client_id, :client_secret, :user_agent, @@ -6,7 +6,7 @@ module Configurable attr_writer :api_endpoint class << self - # List of configurable keys for PactasItero::Client + # List of configurable keys for Billwerk::Client def keys @keys ||= [ :bearer_token, @@ -28,8 +28,8 @@ def configure # Reset configuration options to default values def reset! - PactasItero::Configurable.keys.each do |key| - send(:"#{key}=", PactasItero::Default.options[key]) + Billwerk::Configurable.keys.each do |key| + send(:"#{key}=", Billwerk::Default.options[key]) end self end @@ -43,17 +43,17 @@ def api_endpoint end def sandbox_api_endpoint - PactasItero::Default.sandbox_api_endpoint + Billwerk::Default.sandbox_api_endpoint end def production_api_endpoint - PactasItero::Default.production_api_endpoint + Billwerk::Default.production_api_endpoint end private def options - Hash[PactasItero::Configurable.keys.map{|key| [key, send(:"#{key}")]}] + Hash[Billwerk::Configurable.keys.map{|key| [key, send(:"#{key}")]}] end end end diff --git a/lib/pactas_itero/default.rb b/lib/billwerk/default.rb similarity index 61% rename from lib/pactas_itero/default.rb rename to lib/billwerk/default.rb index 6396003..981ae34 100644 --- a/lib/pactas_itero/default.rb +++ b/lib/billwerk/default.rb @@ -1,25 +1,25 @@ -require 'pactas_itero/response/raise_error' -require 'pactas_itero/version' +require 'billwerk/response/raise_error' +require 'billwerk/version' require 'faraday_middleware' -module PactasItero +module Billwerk # Default configuration options for {Client} module Default SANDBOX_API_ENDPOINT = "https://sandbox.billwerk.com".freeze - PRODUCTION_API_ENDPOINT = "https://itero.pactas.com".freeze + PRODUCTION_API_ENDPOINT = "https://app.billwerk.com".freeze PRODUCTION = false - USER_AGENT = "Pactas.Itero Ruby Gem #{PactasItero::VERSION}".freeze + USER_AGENT = "Billwerk Ruby Gem #{Billwerk::VERSION}".freeze MEDIA_TYPE = "application/json" MIDDLEWARE = Faraday::RackBuilder.new do |builder| builder.request :json - builder.use PactasItero::Response::RaiseError + builder.use Billwerk::Response::RaiseError builder.response :rashify builder.request :url_encoded builder.response :json, :content_type => /\bjson$/ @@ -30,11 +30,11 @@ module Default class << self def options - Hash[PactasItero::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Billwerk::Configurable.keys.map{|key| [key, send(key)]}] end def api_endpoint - ENV['PACTAS_ITERO_ENDPOINT'] + ENV['BILLWERK_ENDPOINT'] end def sandbox_api_endpoint @@ -50,19 +50,19 @@ def production end def client_id - ENV['PACTAS_ITERO_CLIENT_ID'] + ENV['BILLWERK_CLIENT_ID'] end def client_secret - ENV['PACTAS_ITERO_CLIENT_SECRET'] + ENV['BILLWERK_CLIENT_SECRET'] end def bearer_token - ENV['PACTAS_ITERO_BEARER_TOKEN'] + ENV['BILLWERK_BEARER_TOKEN'] end def default_media_type - ENV['PACTAS_ITERO_CLIENT_DEFAULT_MEDIA_TYPE'] || MEDIA_TYPE + ENV['BILLWERK_CLIENT_DEFAULT_MEDIA_TYPE'] || MEDIA_TYPE end def middleware @@ -70,7 +70,7 @@ def middleware end def user_agent - ENV['PACTAS_ITERO_USER_AGENT'] || USER_AGENT + ENV['BILLWERK_USER_AGENT'] || USER_AGENT end end end diff --git a/lib/pactas_itero/error.rb b/lib/billwerk/error.rb similarity index 67% rename from lib/pactas_itero/error.rb rename to lib/billwerk/error.rb index eaee863..3ef70fb 100644 --- a/lib/pactas_itero/error.rb +++ b/lib/billwerk/error.rb @@ -1,32 +1,32 @@ -module PactasItero - # Custom error class for rescuing from all Pactas errors +module Billwerk + # Custom error class for rescuing from all Billwerk errors class Error < StandardError - # Returns the appropriate PactasItero::Error sublcass based + # Returns the appropriate Billwerk::Error sublcass based # on status and response message # # @param [Hash] response HTTP response - # @return [PactasItero::Error] + # @return [Billwerk::Error] def self.from_response(response) status = response[:status].to_i body = response[:body].to_s headers = response[:response_headers] if klass = case status - when 400 then PactasItero::BadRequest + when 400 then Billwerk::BadRequest when 401 then error_for_401(headers) when 403 then error_for_403(body) - when 404 then PactasItero::NotFound - when 406 then PactasItero::NotAcceptable - when 409 then PactasItero::Conflict - when 415 then PactasItero::UnsupportedMediaType - when 422 then PactasItero::UnprocessableEntity - when 400..499 then PactasItero::ClientError - when 500 then PactasItero::InternalServerError - when 501 then PactasItero::NotImplemented - when 502 then PactasItero::BadGateway - when 503 then PactasItero::ServiceUnavailable - when 500..599 then PactasItero::ServerError + when 404 then Billwerk::NotFound + when 406 then Billwerk::NotAcceptable + when 409 then Billwerk::Conflict + when 415 then Billwerk::UnsupportedMediaType + when 422 then Billwerk::UnprocessableEntity + when 400..499 then Billwerk::ClientError + when 500 then Billwerk::InternalServerError + when 501 then Billwerk::NotImplemented + when 502 then Billwerk::BadGateway + when 503 then Billwerk::ServiceUnavailable + when 500..599 then Billwerk::ServerError end klass.new(response) end @@ -40,10 +40,10 @@ def initialize(response=nil) # Returns most appropriate error for 401 HTTP status code # @private def self.error_for_401(headers) - if PactasItero::OneTimePasswordRequired.required_header(headers) - PactasItero::OneTimePasswordRequired + if Billwerk::OneTimePasswordRequired.required_header(headers) + Billwerk::OneTimePasswordRequired else - PactasItero::Unauthorized + Billwerk::Unauthorized end end @@ -51,11 +51,11 @@ def self.error_for_401(headers) # @private def self.error_for_403(body) if body =~ /rate limit exceeded/i - PactasItero::TooManyRequests + Billwerk::TooManyRequests elsif body =~ /login attempts exceeded/i - PactasItero::TooManyLoginAttempts + Billwerk::TooManyLoginAttempts else - PactasItero::Forbidden + Billwerk::Forbidden end end @@ -134,21 +134,21 @@ def redact_url(url_string) # Raised on errors in the 400-499 range class ClientError < Error; end - # Raised when Pactas returns a 400 HTTP status code + # Raised when Billwerk returns a 400 HTTP status code class BadRequest < ClientError; end - # Raised when Pactas returns a 401 HTTP status code + # Raised when Billwerk returns a 401 HTTP status code class Unauthorized < ClientError; end - # Raised when Pactas returns a 401 HTTP status code - # and headers include "X-Pactas-OTP" + # Raised when Billwerk returns a 401 HTTP status code + # and headers include "X-Billwerk-OTP" class OneTimePasswordRequired < ClientError #@private OTP_DELIVERY_PATTERN = /required; (\w+)/i #@private def self.required_header(headers) - OTP_DELIVERY_PATTERN.match headers['X-Pactas-OTP'].to_s + OTP_DELIVERY_PATTERN.match headers['X-Billwerk-OTP'].to_s end # Delivery method for the user's OTP @@ -167,45 +167,45 @@ def delivery_method_from_header end end - # Raised when Pactas returns a 403 HTTP status code + # Raised when Billwerk returns a 403 HTTP status code class Forbidden < ClientError; end - # Raised when Pactas returns a 403 HTTP status code + # Raised when Billwerk returns a 403 HTTP status code # and body matches 'rate limit exceeded' class TooManyRequests < Forbidden; end - # Raised when Pactas returns a 403 HTTP status code + # Raised when Billwerk returns a 403 HTTP status code # and body matches 'login attempts exceeded' class TooManyLoginAttempts < Forbidden; end - # Raised when Pactas returns a 404 HTTP status code + # Raised when Billwerk returns a 404 HTTP status code class NotFound < ClientError; end - # Raised when Pactas returns a 406 HTTP status code + # Raised when Billwerk returns a 406 HTTP status code class NotAcceptable < ClientError; end - # Raised when Pactas returns a 409 HTTP status code + # Raised when Billwerk returns a 409 HTTP status code class Conflict < ClientError; end - # Raised when Pactas returns a 414 HTTP status code + # Raised when Billwerk returns a 414 HTTP status code class UnsupportedMediaType < ClientError; end - # Raised when Pactas returns a 422 HTTP status code + # Raised when Billwerk returns a 422 HTTP status code class UnprocessableEntity < ClientError; end # Raised on errors in the 500-599 range class ServerError < Error; end - # Raised when Pactas returns a 500 HTTP status code + # Raised when Billwerk returns a 500 HTTP status code class InternalServerError < ServerError; end - # Raised when Pactas returns a 501 HTTP status code + # Raised when Billwerk returns a 501 HTTP status code class NotImplemented < ServerError; end - # Raised when Pactas returns a 502 HTTP status code + # Raised when Billwerk returns a 502 HTTP status code class BadGateway < ServerError; end - # Raised when Pactas returns a 503 HTTP status code + # Raised when Billwerk returns a 503 HTTP status code class ServiceUnavailable < ServerError; end # Raised when client fails to provide valid Content-Type diff --git a/lib/pactas_itero/ext/hash/camelize_keys.rb b/lib/billwerk/ext/hash/camelize_keys.rb similarity index 100% rename from lib/pactas_itero/ext/hash/camelize_keys.rb rename to lib/billwerk/ext/hash/camelize_keys.rb diff --git a/lib/pactas_itero/response/raise_error.rb b/lib/billwerk/response/raise_error.rb similarity index 61% rename from lib/pactas_itero/response/raise_error.rb rename to lib/billwerk/response/raise_error.rb index 5599fc4..14aa7b6 100644 --- a/lib/pactas_itero/response/raise_error.rb +++ b/lib/billwerk/response/raise_error.rb @@ -1,18 +1,18 @@ require 'faraday' -require 'pactas_itero/error' +require 'billwerk/error' -module PactasItero +module Billwerk # Faraday response middleware module Response - # This class raises an PactasItero-flavored exception based + # This class raises an Billwerk-flavored exception based # HTTP status codes returned by the API class RaiseError < Faraday::Response::Middleware private def on_complete(response) - if error = PactasItero::Error.from_response(response) + if error = Billwerk::Error.from_response(response) raise error end end diff --git a/lib/pactas_itero/version.rb b/lib/billwerk/version.rb similarity index 62% rename from lib/pactas_itero/version.rb rename to lib/billwerk/version.rb index 027cc8f..2f3384b 100644 --- a/lib/pactas_itero/version.rb +++ b/lib/billwerk/version.rb @@ -1,3 +1,3 @@ -module PactasItero +module Billwerk VERSION = "0.3.0".freeze end diff --git a/lib/pactas_itero/api.rb b/lib/pactas_itero/api.rb deleted file mode 100644 index 3a9c14a..0000000 --- a/lib/pactas_itero/api.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'pactas_itero/ext/hash/camelize_keys' -require 'pactas_itero/api/oauth' -require 'pactas_itero/api/rated_items' -require 'pactas_itero/api/customers' -require 'pactas_itero/api/contracts' -require 'pactas_itero/api/orders' -require 'pactas_itero/api/invoices' -require "pactas_itero/api/payment_transactions" - -module PactasItero - module Api - include PactasItero::Api::OAuth - include PactasItero::Api::RatedItems - include PactasItero::Api::Customers - include PactasItero::Api::Contracts - include PactasItero::Api::Orders - include PactasItero::Api::Invoices - include PactasItero::Api::PaymentTransactions - end -end diff --git a/spec/pactas_itero/api/contracts_spec.rb b/spec/pactas_itero/api/contracts_spec.rb index 638ba4d..3604328 100644 --- a/spec/pactas_itero/api/contracts_spec.rb +++ b/spec/pactas_itero/api/contracts_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe PactasItero::Api::Customers do +describe Billwerk::Api::Customers do describe '.customer_contracts' do it 'requests the correct resource' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/customers/535783241d8dd00fa0db6b2a/contracts'). to_return( body: fixture('contracts.json'), @@ -16,7 +16,7 @@ end it 'returns an array of contracts' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/customers/535783241d8dd00fa0db6b2a/contracts'). to_return( body: fixture('contracts.json'), @@ -31,7 +31,7 @@ describe '.contracts' do it 'requests the correct resource' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/contracts'). to_return( body: fixture('contracts.json'), @@ -44,7 +44,7 @@ end it 'returns an array of contracts' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/contracts'). to_return( body: fixture('contracts.json'), @@ -59,7 +59,7 @@ describe ".contract_cancellation_preview" do it "requests the correct resource" do - client = PactasItero::Client.new(bearer_token: "bt") + client = Billwerk::Client.new(bearer_token: "bt") request = stub_get("/api/v1/contracts/some_contract_id/cancellationPreview").to_return( body: fixture("contract_cancellation_preview_response.json"), headers: { content_type: "application/json; charset=utf-8" } @@ -71,7 +71,7 @@ end it 'returns the next possible cancellation date' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get("/api/v1/contracts/some_contract_id/cancellationPreview").to_return( body: fixture("contract_cancellation_preview_response.json"), headers: { content_type: "application/json; charset=utf-8" } @@ -87,7 +87,7 @@ describe '.update_contract' do it 'requests the correct resource' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_patch('/api/v1/contracts/contract-id'). with(body: { EndDate: '2014-05-23T13:12:47.0760000Z' }.to_json). to_return( @@ -103,7 +103,7 @@ describe '.contract' do it 'requests the correct resource' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/contracts/5357bc4f1d8dd00fa0db6c31'). to_return( body: fixture('contract.json'), @@ -118,7 +118,7 @@ describe ".terminate_contract" do it "requests the correct resource" do - client = PactasItero::Client.new(bearer_token: "bt") + client = Billwerk::Client.new(bearer_token: "bt") request = stub_post("/api/v1/contracts/5922f50b81b1f007e0e4d738/end"). with( body: { EndDate: "2017-10-01T14:51:29.3390000Z" }.to_json, @@ -139,7 +139,7 @@ describe ".get_self_service_token_for_contract" do it "requests the correct resource" do - client = PactasItero::Client.new(bearer_token: "bt") + client = Billwerk::Client.new(bearer_token: "bt") request = stub_get("/api/v1/contracts/5357bc4f1d8dd00fa0db6c31/SelfServiceToken").to_return( body: fixture("self_service_token.json"), headers: { content_type: "application/json; charset=utf-8" }, @@ -151,7 +151,7 @@ end it "returns a self service token" do - client = PactasItero::Client.new(bearer_token: "bt") + client = Billwerk::Client.new(bearer_token: "bt") stub_get("/api/v1/contracts/5357bc4f1d8dd00fa0db6c31/SelfServiceToken").to_return( body: fixture("self_service_token.json"), headers: { content_type: "application/json; charset=utf-8" }, diff --git a/spec/pactas_itero/api/customers_spec.rb b/spec/pactas_itero/api/customers_spec.rb index 74a00ba..8a2fbbe 100644 --- a/spec/pactas_itero/api/customers_spec.rb +++ b/spec/pactas_itero/api/customers_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe PactasItero::Api::Customers do +describe Billwerk::Api::Customers do describe ".create_customer" do it "requests the correct resource" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') post_data = { "Address" => { "City" => "Example City", @@ -50,7 +50,7 @@ end it 'returns the created customer' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') post_data = { "Address" => { "City" => "Example City", @@ -114,7 +114,7 @@ describe ".customers" do it "requests the correct resource" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/customers'). to_return( body: fixture('customers.json'), @@ -127,7 +127,7 @@ end it 'returns an array of customers' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/customers'). to_return( body: fixture('customers.json'), @@ -162,7 +162,7 @@ describe ".customer" do it "requests the correct resource" do - client = PactasItero::Client.new(bearer_token: "bearer_token") + client = Billwerk::Client.new(bearer_token: "bearer_token") request = stub_get("/api/v1/customers/customer-id").to_return( body: fixture("customer.json"), headers: { content_type: "application/json; charset=utf-8" }, @@ -174,7 +174,7 @@ end it "returns the customer details" do - client = PactasItero::Client.new(bearer_token: "bearer_token") + client = Billwerk::Client.new(bearer_token: "bearer_token") stub_get("/api/v1/customers/customer-id").to_return( body: fixture("customer.json"), headers: { content_type: "application/json; charset=utf-8" }, @@ -203,7 +203,7 @@ describe '.update_customer' do it 'requests the correct resource' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_patch('/api/v1/customers/customer-id'). with( body: { diff --git a/spec/pactas_itero/api/invoices_spec.rb b/spec/pactas_itero/api/invoices_spec.rb index 10e64b5..6d62d25 100644 --- a/spec/pactas_itero/api/invoices_spec.rb +++ b/spec/pactas_itero/api/invoices_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe PactasItero::Api::Invoices do +describe Billwerk::Api::Invoices do describe '.invoices' do it 'requests the correct resource' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/invoices'). to_return( body: fixture('invoices.json'), @@ -16,7 +16,7 @@ end it 'returns an array of contracts' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/invoices'). to_return( body: fixture('invoices.json'), @@ -31,7 +31,7 @@ describe '.invoices_from' do it 'requests the correct resource' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/invoices?from=54b67d9e995ec90bc8f37718'). to_return( body: fixture('invoices.json'), @@ -44,7 +44,7 @@ end it 'requests the correct resource, if from parameter is nil' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/invoices'). to_return( body: fixture('invoices.json'), @@ -57,7 +57,7 @@ end it 'returns an array of contracts' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/invoices?from=54b67d9e995ec90bc8f37718'). to_return( body: fixture('invoices.json'), @@ -72,7 +72,7 @@ describe '.invoice' do it 'requests the correct resource' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/invoices/54b67d9e995ec90bc8f37718'). to_return( body: fixture('invoice.json'), diff --git a/spec/pactas_itero/api/oauth_spec.rb b/spec/pactas_itero/api/oauth_spec.rb index a6ff841..1e83c10 100644 --- a/spec/pactas_itero/api/oauth_spec.rb +++ b/spec/pactas_itero/api/oauth_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -describe PactasItero::Api::OAuth do +describe Billwerk::Api::OAuth do describe "#token" do it "requests the correct resource" do client_credentials_request = stub_post("https://sandbox.billwerk.com/oauth/token").with( @@ -11,7 +11,7 @@ }, ) - client = PactasItero::Client.new(client_id: "a_client_id", client_secret: "a_client_secret") + client = Billwerk::Client.new(client_id: "a_client_id", client_secret: "a_client_secret") client.token @@ -33,7 +33,7 @@ }, ) - client = PactasItero::Client.new(client_id: "a_client_id", client_secret: "a_client_secret") + client = Billwerk::Client.new(client_id: "a_client_id", client_secret: "a_client_secret") bearer_token = client.token expect(bearer_token.access_token).to eq("top_secret_access_token") diff --git a/spec/pactas_itero/api/orders_spec.rb b/spec/pactas_itero/api/orders_spec.rb index 3619d58..5a53a3a 100644 --- a/spec/pactas_itero/api/orders_spec.rb +++ b/spec/pactas_itero/api/orders_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe PactasItero::Api::Orders do +describe Billwerk::Api::Orders do describe ".create_order" do it "requests the correct resource" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') post_data = { ContractId: "5370e5ab9e40071fd01e01e0", Cart: { @@ -28,7 +28,7 @@ end it 'returns the created order' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') post_data = { ContractId: "5370e5ab9e40071fd01e01e0", Cart: { @@ -56,7 +56,7 @@ describe '.order' do it 'requests the correct resource' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get('/api/v1/orders/5357bc4f1d8dd00fa0db6c31'). to_return( body: fixture('order.json'), @@ -71,7 +71,7 @@ describe ".commit_order" do it "requests the correct resource" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_post('/api/v1/orders/537dfcab9e400760b4cd6347/commit'). with(body: {}.to_json). to_return( @@ -85,7 +85,7 @@ end it 'returns the updated contract' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_post('/api/v1/orders/537dfcab9e400760b4cd6347/commit'). with(body: {}.to_json). to_return( diff --git a/spec/pactas_itero/api/payment_transactions_spec.rb b/spec/pactas_itero/api/payment_transactions_spec.rb index 4c4ad46..e896918 100644 --- a/spec/pactas_itero/api/payment_transactions_spec.rb +++ b/spec/pactas_itero/api/payment_transactions_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true require "spec_helper" -describe PactasItero::Api::PaymentTransactions do +describe Billwerk::Api::PaymentTransactions do describe ".payment_transaction" do it "requests the correct resource" do - client = PactasItero::Client.new(bearer_token: "bearer_token") + client = Billwerk::Client.new(bearer_token: "bearer_token") request = stub_get("/api/v1/PaymentTransactions/payment_transaction_id").to_return( body: fixture("payment_transaction.json"), headers: { content_type: "application/json; charset=utf-8" }, @@ -16,7 +16,7 @@ end it "returns the payment transaction details" do - client = PactasItero::Client.new(bearer_token: "bearer_token") + client = Billwerk::Client.new(bearer_token: "bearer_token") stub_get("/api/v1/PaymentTransactions/payment_transaction_id").to_return( body: fixture("payment_transaction.json"), headers: { content_type: "application/json; charset=utf-8" }, diff --git a/spec/pactas_itero/api/rated_items_spec.rb b/spec/pactas_itero/api/rated_items_spec.rb index 6db9239..9a2bf1a 100644 --- a/spec/pactas_itero/api/rated_items_spec.rb +++ b/spec/pactas_itero/api/rated_items_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe PactasItero::Api::RatedItems do +describe Billwerk::Api::RatedItems do describe ".create_rated_item" do it "requests the correct resource" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') post_data = { PeriodStart: '2014-09-19T08:18:51.907Z', PeriodEnd: '2014-09-19T08:19:51.907Z', @@ -35,7 +35,7 @@ end it 'returns the created rated item' do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') post_data = { PeriodStart: '2014-09-19T08:18:51.907Z', PeriodEnd: '2014-09-19T08:19:51.907Z', @@ -74,7 +74,7 @@ describe ".rated_items" do it "returns rated items" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') stub_get("/api/v1/contracts/contract-id/ratedItems"). to_return( body: fixture("rated_items.json"), @@ -98,7 +98,7 @@ describe ".delete_rated_item" do it "deletes a rated item" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') stub_delete("/api/v1/ratedItems/rated-item-id"). to_return( body: "", diff --git a/spec/pactas_itero/client_spec.rb b/spec/pactas_itero/client_spec.rb index 3761baf..4562bfa 100644 --- a/spec/pactas_itero/client_spec.rb +++ b/spec/pactas_itero/client_spec.rb @@ -1,26 +1,26 @@ require 'spec_helper' require 'json' -describe PactasItero::Client do +describe Billwerk::Client do before do - PactasItero.reset! + Billwerk.reset! end describe "module configuration" do before do - PactasItero.configure do |config| - PactasItero::Configurable.keys.each do |key| + Billwerk.configure do |config| + Billwerk::Configurable.keys.each do |key| config.send("#{key}=", "the #{key} value") end end end it "inherits the module configuration" do - client = PactasItero::Client.new + client = Billwerk::Client.new - PactasItero::Configurable.keys.each do |key| + Billwerk::Configurable.keys.each do |key| expect(client.instance_variable_get(:"@#{key}")).to eq("the #{key} value") end end @@ -36,15 +36,15 @@ end it "overrides module configuration" do - client = PactasItero::Client.new(@opts) + client = Billwerk::Client.new(@opts) expect(client.client_id).to eq("the_client_id") expect(client.client_secret).to eq("the_client_secret") - expect(client.user_agent).to eq(PactasItero.user_agent) + expect(client.user_agent).to eq(Billwerk.user_agent) end it "can set configuration after initialization" do - client = PactasItero::Client.new + client = Billwerk::Client.new client.configure do |config| @opts.each do |key, value| config.send("#{key}=", value) @@ -53,14 +53,14 @@ expect(client.client_id).to eq("the_client_id") expect(client.client_secret).to eq("the_client_secret") - expect(client.user_agent).to eq(PactasItero.user_agent) + expect(client.user_agent).to eq(Billwerk.user_agent) end end end describe ".get" do it "requests the given resource using get" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get("/something?foo=bar") client.get "/something", foo: "bar" @@ -69,7 +69,7 @@ end it "passes along request headers" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get("/"). with(query: { foo: "bar" }, headers: { accept: "text/plain" }) client.get "/", foo: "bar", accept: "text/plain" @@ -80,7 +80,7 @@ describe ".head" do it "requests the given resource using head" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_head("/something?foo=bar") client.head "/something", foo: "bar" @@ -89,7 +89,7 @@ end it "passes along request headers" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_head("/"). with(query: { foo: "bar" }, headers: { accept: "text/plain" }) @@ -101,7 +101,7 @@ describe ".post" do it "requests the given resource using post" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_post("/something"). with(body: { foo: "bar" }.to_json) @@ -111,7 +111,7 @@ end it "passes along request headers" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') headers = { "X-Foo" => "bar" } request = stub_post("/"). with(body: { foo: "bar" }.to_json, headers: headers) @@ -124,7 +124,7 @@ describe ".put" do it "requests the given resource using put" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_put("/something"). with(body: { foo: "bar" }.to_json) @@ -134,7 +134,7 @@ end it "passes along request headers" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') headers = { "X-Foo" => "bar" } request = stub_put("/"). with(body: { foo: "bar" }.to_json, headers: headers) @@ -147,7 +147,7 @@ describe ".patch" do it "requests the given resource using patch" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_patch("/something"). with(body: { foo: "bar" }.to_json) @@ -157,7 +157,7 @@ end it "passes along request headers" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') headers = { "X-Foo" => "bar" } request = stub_patch("/"). with(body: { foo: "bar" }.to_json, headers: headers) @@ -170,7 +170,7 @@ describe ".delete" do it "requests the given resource using delete" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_delete("/something") client.delete "/something" @@ -179,7 +179,7 @@ end it "passes along request headers" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') headers = { "X-Foo" => "bar" } request = stub_delete("/").with(headers: headers) @@ -192,21 +192,21 @@ describe "when making requests" do it 'uses the sandbox endpoint by default' do - client = PactasItero::Client.new + client = Billwerk::Client.new expect(client.api_endpoint).to eq "https://sandbox.billwerk.com/" end it "uses the production endpoint when production is set to true" do - client = PactasItero::Client.new(production: true) + client = Billwerk::Client.new(production: true) - expect(client.api_endpoint).to eq 'https://itero.pactas.com/' + expect(client.api_endpoint).to eq 'https://app.billwerk.com/' end it "sets a default user agent" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') request = stub_get("/"). - with(headers: { user_agent: PactasItero::Default.user_agent }) + with(headers: { user_agent: Billwerk::Default.user_agent }) client.get "/" @@ -215,7 +215,7 @@ it "accepts a custom user agent" do user_agent = "Mozilla/1.0 (Win3.1)" - client = PactasItero::Client.new(user_agent: user_agent, bearer_token: 'bt') + client = Billwerk::Client.new(user_agent: user_agent, bearer_token: 'bt') request = stub_get("/").with(headers: { user_agent: user_agent }) client.get "/" @@ -226,7 +226,7 @@ it 'creates the correct auth headers with supplied bearer_token' do token = 'the_bearer_token' request = stub_get("/").with(headers: { authorization: "Bearer #{token}" }) - client = PactasItero::Client.new(bearer_token: token) + client = Billwerk::Client.new(bearer_token: token) client.get "/" @@ -235,7 +235,7 @@ it 'creates the correct auth headers with supplied bearer_token' do token = OpenStruct.new(access_token: 'the_bearer_token') - client = PactasItero::Client.new(bearer_token: token) + client = Billwerk::Client.new(bearer_token: token) request = stub_get("/").with(headers: { authorization: "Bearer #{token.access_token}" }) @@ -247,21 +247,21 @@ context "error handling" do it "raises on 404" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') stub_get('/four_oh_four').to_return(status: 404) - expect { client.get('/four_oh_four') }.to raise_error PactasItero::NotFound + expect { client.get('/four_oh_four') }.to raise_error Billwerk::NotFound end it "raises on 500" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') stub_get('/five_oh_oh').to_return(status: 500) - expect { client.get('/five_oh_oh') }.to raise_error PactasItero::InternalServerError + expect { client.get('/five_oh_oh') }.to raise_error Billwerk::InternalServerError end it "includes a message" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') stub_get('/with_message').to_return( status: 422, headers: { content_type: "application/json" }, @@ -269,38 +269,38 @@ ) expect { client.get('/with_message') }.to raise_error( - PactasItero::UnprocessableEntity, + Billwerk::UnprocessableEntity, "GET https://sandbox.billwerk.com/with_message: " \ "422 - 'Something' is not a valid ObjectId. Expected a 24 digit hex string.", ) end it "raises a ClientError on unknown client errors" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') stub_get('/something').to_return( status: 418, headers: { content_type: "application/json" }, body: { message: "I'm a teapot" }.to_json ) - expect { client.get('/something') }.to raise_error PactasItero::ClientError + expect { client.get('/something') }.to raise_error Billwerk::ClientError end it "raises a ServerError on unknown server errors" do - client = PactasItero::Client.new(bearer_token: 'bt') + client = Billwerk::Client.new(bearer_token: 'bt') stub_get('/something').to_return( status: 509, headers: { content_type: "application/json" }, body: { message: "Bandwidth exceeded" }.to_json ) - expect { client.get('/something') }.to raise_error PactasItero::ServerError + expect { client.get('/something') }.to raise_error Billwerk::ServerError end end describe '.sandbox_api_endpoint' do it 'returns url of the sandbox endpoint' do - client = PactasItero::Client.new + client = Billwerk::Client.new expect(client.sandbox_api_endpoint).to eq "https://sandbox.billwerk.com" end @@ -308,9 +308,9 @@ describe '.production_api_endpoint' do it 'returns url of the sandbox endpoint' do - client = PactasItero::Client.new + client = Billwerk::Client.new - expect(client.production_api_endpoint).to eq 'https://itero.pactas.com' + expect(client.production_api_endpoint).to eq 'https://app.billwerk.com' end end end diff --git a/spec/pactas_itero_spec.rb b/spec/pactas_itero_spec.rb index 53b8359..8d1ae88 100644 --- a/spec/pactas_itero_spec.rb +++ b/spec/pactas_itero_spec.rb @@ -1,37 +1,37 @@ require 'spec_helper' -describe PactasItero do +describe Billwerk do it "sets defaults" do - PactasItero::Configurable.keys.each do |key| - expect(PactasItero.instance_variable_get(:"@#{key}")).to eq(PactasItero::Default.send(key)) + Billwerk::Configurable.keys.each do |key| + expect(Billwerk.instance_variable_get(:"@#{key}")).to eq(Billwerk::Default.send(key)) end end describe ".client" do - it "creates an PactasItero::Client" do - expect(PactasItero.client).to be_kind_of PactasItero::Client + it "creates an Billwerk::Client" do + expect(Billwerk.client).to be_kind_of Billwerk::Client end it "creates new client everytime" do - expect(PactasItero.client).to_not eq(PactasItero.client) + expect(Billwerk.client).to_not eq(Billwerk.client) end it "allows stubbing the method" do - pactas_client = instance_double(PactasItero::Client) - allow(PactasItero).to receive(:client).and_return(pactas_client) + billwerk_client = instance_double(Billwerk::Client) + allow(Billwerk).to receive(:client).and_return(billwerk_client) - expect(PactasItero.client).to be_kind_of RSpec::Mocks::InstanceVerifyingDouble + expect(Billwerk.client).to be_kind_of RSpec::Mocks::InstanceVerifyingDouble end end describe ".configure" do - PactasItero::Configurable.keys.each do |key| + Billwerk::Configurable.keys.each do |key| it "sets the #{key.to_s.gsub('_', ' ')}" do - PactasItero.configure do |config| + Billwerk.configure do |config| config.send("#{key}=", key) end - expect(PactasItero.instance_variable_get(:"@#{key}")).to eq(key) + expect(Billwerk.instance_variable_get(:"@#{key}")).to eq(key) end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0e2fd8b..d9c5123 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,7 +12,7 @@ end require 'json' -require 'pactas_itero' +require 'billwerk' require 'rspec' require 'webmock/rspec' @@ -39,7 +39,7 @@ ] config.after(:each) do - PactasItero.reset! + Billwerk.reset! end end @@ -51,50 +51,50 @@ def fixture(file) File.new(fixture_path + '/' + file) end -def pactas_api_endpoint - PactasItero::Default::SANDBOX_API_ENDPOINT +def billwerk_api_endpoint + Billwerk::Default::SANDBOX_API_ENDPOINT end -def pactas_api_url(url) - url =~ /^http/ ? url : "#{pactas_api_endpoint}#{url}" +def billwerk_api_url(url) + url =~ /^http/ ? url : "#{billwerk_api_endpoint}#{url}" end def a_delete(path) - a_request(:delete, pactas_api_url(path)) + a_request(:delete, billwerk_api_url(path)) end def a_get(path) - a_request(:get, pactas_api_url(path)) + a_request(:get, billwerk_api_url(path)) end def a_post(path) - a_request(:post, pactas_api_url(path)) + a_request(:post, billwerk_api_url(path)) end def a_put(path) - a_request(:put, pactas_api_url(path)) + a_request(:put, billwerk_api_url(path)) end def stub_delete(path) - stub_request(:delete, pactas_api_url(path)) + stub_request(:delete, billwerk_api_url(path)) end def stub_get(path) - stub_request(:get, pactas_api_url(path)) + stub_request(:get, billwerk_api_url(path)) end def stub_head(path) - stub_request(:head, pactas_api_url(path)) + stub_request(:head, billwerk_api_url(path)) end def stub_post(path) - stub_request(:post, pactas_api_url(path)) + stub_request(:post, billwerk_api_url(path)) end def stub_put(path) - stub_request(:put, pactas_api_url(path)) + stub_request(:put, billwerk_api_url(path)) end def stub_patch(path) - stub_request(:patch, pactas_api_url(path)) + stub_request(:patch, billwerk_api_url(path)) end