gotransverse-tract-api 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gotransverse-tract-api.rb +51 -1
- data/lib/gotransverse-tract-api/api_data.rb +259 -0
- data/lib/gotransverse-tract-api/billing_account/adjustment.rb +205 -5
- data/lib/gotransverse-tract-api/billing_account/billing_account.rb +146 -13
- data/lib/gotransverse-tract-api/billing_account/invoice.rb +2 -1
- data/lib/gotransverse-tract-api/billing_account/payment.rb +90 -9
- data/lib/gotransverse-tract-api/billing_account/refund.rb +15 -1
- data/lib/gotransverse-tract-api/order/order_item.rb +179 -7
- data/lib/gotransverse-tract-api/order/organization.rb +15 -1
- data/lib/gotransverse-tract-api/order/people.rb +14 -16
- data/lib/gotransverse-tract-api/order/sales_order.rb +253 -6
- data/lib/gotransverse-tract-api/service/service.rb +273 -24
- data/lib/gotransverse-tract-api/service/service_resource.rb +65 -7
- data/lib/gotransverse-tract-api/usage/usage_event.rb +58 -3
- data/lib/gotransverse-tract-api/usage/usage_main.rb +19 -0
- data/lib/gotransverse-tract-api/usage/usage_some.rb +24 -0
- data/lib/gotransverse-tract-api/version.rb +1 -1
- data/spec/gotransverse-tract-api/billing_account/adjustment_spec.rb +190 -0
- data/spec/gotransverse-tract-api/billing_account/billing_account_spec.rb +380 -0
- data/spec/gotransverse-tract-api/billing_account/invoice_spec.rb +43 -0
- data/spec/gotransverse-tract-api/billing_account/payment_spec.rb +104 -2
- data/spec/gotransverse-tract-api/billing_account/refund_spec.rb +30 -0
- data/spec/gotransverse-tract-api/order/order_item_spec.rb +169 -0
- data/spec/gotransverse-tract-api/order/organization_spec.rb +32 -0
- data/spec/gotransverse-tract-api/order/people_spec.rb +32 -0
- data/spec/gotransverse-tract-api/order/sales_order_spec.rb +209 -0
- data/spec/gotransverse-tract-api/service/service_resource_spec.rb +83 -0
- data/spec/gotransverse-tract-api/service/service_spec.rb +194 -0
- data/spec/gotransverse-tract-api/usage/usage_event_spec.rb +57 -0
- metadata +27 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 2262c8dfe32caf5a06afc9eb322a064301d141d6
         | 
| 4 | 
            +
              data.tar.gz: 132028b0ab05e06d987d8af55f064d62892a46b2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: fcea9c7ea29d482546b744b97cc5acc94e7980b607c4987c3b525fb4a5bf031d2bb4a8897245d3fabf29b005de3182a1324114f280551180b10af31a79fd1997
         | 
| 7 | 
            +
              data.tar.gz: 6eb53434e40f6de3291bfb89f93445730a0540c8bbd76e2f914cab9a86f9a33c69b3c0a30df6037f3599a76e945f7c9a91413431ccb525cfdcf5b900472e8a10
         | 
| @@ -2,6 +2,7 @@ require "gotransverse-tract-api/version" | |
| 2 2 |  | 
| 3 3 | 
             
            require "gotransverse-tract-api/configuration"
         | 
| 4 4 | 
             
            require "gotransverse-tract-api/hash"
         | 
| 5 | 
            +
            require "gotransverse-tract-api/api_data"
         | 
| 5 6 |  | 
| 6 7 | 
             
            require "gotransverse-tract-api/billing_account/adjustment"
         | 
| 7 8 | 
             
            require "gotransverse-tract-api/billing_account/adjustment_application"
         | 
| @@ -155,7 +156,11 @@ module GoTransverseTractApi | |
| 155 156 | 
             
              #
         | 
| 156 157 | 
             
              def self.post_request_for(klass, api_params={}, request_body, command)
         | 
| 157 158 | 
             
                api_url = GoTransverseTractApi.get_api_url_for(klass)
         | 
| 158 | 
            -
                 | 
| 159 | 
            +
                if (api_params.empty?)
         | 
| 160 | 
            +
                  api_url = "#{api_url}/#{command}"
         | 
| 161 | 
            +
                else
         | 
| 162 | 
            +
                  api_url = "#{api_url}/#{api_params[:eid]}/#{command}"
         | 
| 163 | 
            +
                end
         | 
| 159 164 |  | 
| 160 165 | 
             
                self.call(klass, api_url, api_params, :post, request_body)
         | 
| 161 166 | 
             
              end
         | 
| @@ -172,6 +177,28 @@ module GoTransverseTractApi | |
| 172 177 | 
             
                self.call(klass, api_url, api_params, :put, request_body.to_xml)
         | 
| 173 178 | 
             
              end
         | 
| 174 179 |  | 
| 180 | 
            +
              #
         | 
| 181 | 
            +
              # Generate XML for request body
         | 
| 182 | 
            +
              #
         | 
| 183 | 
            +
              # @param {hash} data
         | 
| 184 | 
            +
              # @param (String} root element
         | 
| 185 | 
            +
              #
         | 
| 186 | 
            +
             | 
| 187 | 
            +
              def self.generateXML(data, root_elem)
         | 
| 188 | 
            +
                tract_api_ver = GoTransverseTractApi::TARGET_API_VERSION
         | 
| 189 | 
            +
                data[root_elem.to_sym][:xmlns] = "http://www.tractbilling.com/billing/#{tract_api_ver}/domain"
         | 
| 190 | 
            +
             | 
| 191 | 
            +
                builder = Nokogiri::XML::Builder.new do|xml|
         | 
| 192 | 
            +
                  xml.send(root_elem,Hash[data[root_elem.to_sym]]) do
         | 
| 193 | 
            +
                    arr = []
         | 
| 194 | 
            +
                    arr << root_elem.to_sym
         | 
| 195 | 
            +
                    self.process_data(data, arr, xml)
         | 
| 196 | 
            +
                  end
         | 
| 197 | 
            +
                end
         | 
| 198 | 
            +
             | 
| 199 | 
            +
                builder.doc.root.to_xml
         | 
| 200 | 
            +
              end
         | 
| 201 | 
            +
             | 
| 175 202 | 
             
              private
         | 
| 176 203 |  | 
| 177 204 | 
             
              #
         | 
| @@ -244,4 +271,27 @@ module GoTransverseTractApi | |
| 244 271 | 
             
                hsh
         | 
| 245 272 | 
             
              end
         | 
| 246 273 |  | 
| 274 | 
            +
              def self.process_data(data, arr, xml)
         | 
| 275 | 
            +
                data.each do|key,val|
         | 
| 276 | 
            +
                  next if arr.include?(key)
         | 
| 277 | 
            +
                   
         | 
| 278 | 
            +
                  if (val.is_a?Hash)
         | 
| 279 | 
            +
                    if (val.has_key?(:attributes))
         | 
| 280 | 
            +
                      xml.send(key, Hash[data[key][:attributes]]) do
         | 
| 281 | 
            +
                        arr << 'attributes'.to_sym
         | 
| 282 | 
            +
                        self.process_data(data[key],arr,xml)
         | 
| 283 | 
            +
                      end
         | 
| 284 | 
            +
                    else
         | 
| 285 | 
            +
                      xml.send(key, Hash[data[key]])
         | 
| 286 | 
            +
                    end
         | 
| 287 | 
            +
                  elsif (val.is_a?Array)
         | 
| 288 | 
            +
                    val.each do|item|
         | 
| 289 | 
            +
                      self.process_data(item,arr,xml)
         | 
| 290 | 
            +
                    end
         | 
| 291 | 
            +
                  else
         | 
| 292 | 
            +
                    xml.send(key, val)
         | 
| 293 | 
            +
                  end
         | 
| 294 | 
            +
                end
         | 
| 295 | 
            +
              end
         | 
| 296 | 
            +
             | 
| 247 297 | 
             
            end
         | 
| @@ -0,0 +1,259 @@ | |
| 1 | 
            +
            module GoTransverseTractApi
         | 
| 2 | 
            +
              class ApiData
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                def payment_details(invoice, billing_account=nil)
         | 
| 5 | 
            +
                  data = {
         | 
| 6 | 
            +
                    applyPayment: {},
         | 
| 7 | 
            +
                    billingAccount: {
         | 
| 8 | 
            +
                      eid: invoice[:billing_account][:eid]
         | 
| 9 | 
            +
                    },
         | 
| 10 | 
            +
                    invoice: {
         | 
| 11 | 
            +
                      eid: invoice[:invoice][:eid]
         | 
| 12 | 
            +
                    },
         | 
| 13 | 
            +
                    payment: {
         | 
| 14 | 
            +
                      attributes: {
         | 
| 15 | 
            +
                        amount: invoice[:payment][:amount],
         | 
| 16 | 
            +
                        useRecurringPayment: invoice[:payment][:use_recurring_payment]
         | 
| 17 | 
            +
                      },
         | 
| 18 | 
            +
                      creditCardPayment: {
         | 
| 19 | 
            +
                        cardType: invoice[:payment][:credit_card_payment][:card_type],
         | 
| 20 | 
            +
                        cardHolderFirstName: invoice[:payment][:credit_card_payment][:card_holder_first_name],
         | 
| 21 | 
            +
                        cardHolderLastName: invoice[:payment][:credit_card_payment][:card_holder_last_name],
         | 
| 22 | 
            +
                        cardIdentifierNumber: invoice[:payment][:credit_card_payment][:card_identifier_number],
         | 
| 23 | 
            +
                        cardVerificationNumber: invoice[:payment][:credit_card_payment][:card_verification_number],
         | 
| 24 | 
            +
                        cardExpiration: invoice[:payment][:credit_card_payment][:card_expiration]
         | 
| 25 | 
            +
                      },
         | 
| 26 | 
            +
                      billingAccount: {
         | 
| 27 | 
            +
                        eid: invoice[:payment][:billing_account][:eid]
         | 
| 28 | 
            +
                      }
         | 
| 29 | 
            +
                    }
         | 
| 30 | 
            +
                  }
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  if(billing_account)
         | 
| 33 | 
            +
                    data[:payment][:creditCardPayment][:description] = invoice[:payment][:credit_card_payment][:description]
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
                  GoTransverseTractApi.generateXML(data, 'applyPayment')
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
             
         | 
| 38 | 
            +
                # To suspend or deactivate the account
         | 
| 39 | 
            +
                def shutdown(billing_account, eid, root_elem)
         | 
| 40 | 
            +
                  data = {
         | 
| 41 | 
            +
                    billingAccount: {eid: eid},
         | 
| 42 | 
            +
                    reason: {eid: billing_account[:reason][:eid]}
         | 
| 43 | 
            +
                  }
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  data[root_elem.to_sym] = {}
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  GoTransverseTractApi.generateXML(data, root_elem)
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                # Returns {Hash} a list of sales order details
         | 
| 51 | 
            +
                def sales_order_details(sales_order)
         | 
| 52 | 
            +
                  so_details = {
         | 
| 53 | 
            +
                    attributes: {
         | 
| 54 | 
            +
                      referral: sales_order[:referral],
         | 
| 55 | 
            +
                      orderDate: sales_order[:order_date],
         | 
| 56 | 
            +
                      orderStatus: sales_order[:order_status]
         | 
| 57 | 
            +
                    },
         | 
| 58 | 
            +
                    orderItems: {
         | 
| 59 | 
            +
                      attributes: get_page_info(sales_order[:order_items]),
         | 
| 60 | 
            +
                      order_item: {
         | 
| 61 | 
            +
                        attributes: {
         | 
| 62 | 
            +
                          quantity: sales_order[:order_items][:order_item][:quantity]
         | 
| 63 | 
            +
                        },
         | 
| 64 | 
            +
                        products: get_products(sales_order)
         | 
| 65 | 
            +
                      }
         | 
| 66 | 
            +
                    },
         | 
| 67 | 
            +
                    billingAccount: get_billing_account(sales_order[:billing_account])
         | 
| 68 | 
            +
                  }
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  so_details
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                # Returns [Array]  Products 
         | 
| 74 | 
            +
                def get_products(sales_order)
         | 
| 75 | 
            +
                  products = []
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                  items = sales_order[:order_items][:order_item][:products]
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                  (0..items.size - 1).each do|i|
         | 
| 80 | 
            +
                    products << {
         | 
| 81 | 
            +
                      product: {
         | 
| 82 | 
            +
                        attributes: {
         | 
| 83 | 
            +
                          name: items[i][:name],
         | 
| 84 | 
            +
                          description: items[i][:description],
         | 
| 85 | 
            +
                          shortDescription: items[i][:short_description],
         | 
| 86 | 
            +
                          productTypeCode: items[i][:product_type_code],
         | 
| 87 | 
            +
                          productState: items[i][:product_state],
         | 
| 88 | 
            +
                          requiresAgreement: items[i][:requires_agreement],
         | 
| 89 | 
            +
                          serialized: items[i][:serialized],
         | 
| 90 | 
            +
                          taxable: items[i][:taxable],
         | 
| 91 | 
            +
                          trial: items[i][:trial],
         | 
| 92 | 
            +
                          defaultQuantity: items[i][:default_quantity],
         | 
| 93 | 
            +
                          minServiceResources: items[i][:min_service_resources],
         | 
| 94 | 
            +
                          maxServiceResources: items[i][:max_service_resources],
         | 
| 95 | 
            +
                          trialOverride: items[i][:trial_override],
         | 
| 96 | 
            +
                          eid: items[i][:eid]
         | 
| 97 | 
            +
                        },
         | 
| 98 | 
            +
                        productPrices: {
         | 
| 99 | 
            +
                          attributes: get_page_info(items[i][:product_prices]),
         | 
| 100 | 
            +
                          productPrices: get_product_prices(items[i])
         | 
| 101 | 
            +
                        },
         | 
| 102 | 
            +
                        productCategory: {
         | 
| 103 | 
            +
                          name: items[i][:product_category][:name],
         | 
| 104 | 
            +
                          description: items[i][:product_category][:description],
         | 
| 105 | 
            +
                          status: items[i][:product_category][:status],
         | 
| 106 | 
            +
                          eid: items[i][:product_category][:eid]
         | 
| 107 | 
            +
                        },
         | 
| 108 | 
            +
                        actions: get_page_info(items[i][:actions]),
         | 
| 109 | 
            +
                        productUsageRules: get_page_info(items[i][:product_usage_rules])
         | 
| 110 | 
            +
                      }
         | 
| 111 | 
            +
                    }
         | 
| 112 | 
            +
                  end
         | 
| 113 | 
            +
             | 
| 114 | 
            +
                  products
         | 
| 115 | 
            +
                end
         | 
| 116 | 
            +
             | 
| 117 | 
            +
                # Returns [Array]  Product Prices 
         | 
| 118 | 
            +
                def get_product_prices(product)
         | 
| 119 | 
            +
                  product_prices = []
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                  count = product[:product_prices][:total_elements].to_i
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                  (0..count - 1).each do|i|
         | 
| 124 | 
            +
                    product_price = product[:product_prices][:productprices][i]
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                    product_prices << {
         | 
| 127 | 
            +
                      productPrice: {
         | 
| 128 | 
            +
                        attributes: {
         | 
| 129 | 
            +
                          fromDate: product_price[:from_date],
         | 
| 130 | 
            +
                          priceOverride: product_price[:price_override],
         | 
| 131 | 
            +
                          type: product_price[:type],
         | 
| 132 | 
            +
                          recurringPaymentRequired: product_price[:recurring_payment_required],
         | 
| 133 | 
            +
                          eid: product_price[:eid]
         | 
| 134 | 
            +
                        },
         | 
| 135 | 
            +
                        priceRanges: {
         | 
| 136 | 
            +
                          attributes: get_page_info(product_price[:price_ranges]),
         | 
| 137 | 
            +
                          priceRanges: get_price_ranges(product_price)
         | 
| 138 | 
            +
                        }
         | 
| 139 | 
            +
                      }
         | 
| 140 | 
            +
                    }
         | 
| 141 | 
            +
                  end
         | 
| 142 | 
            +
             | 
| 143 | 
            +
                  product_prices
         | 
| 144 | 
            +
                end
         | 
| 145 | 
            +
             | 
| 146 | 
            +
                # Returns [Array]  Price Ranges
         | 
| 147 | 
            +
                def get_price_ranges(product_price)
         | 
| 148 | 
            +
                  price_ranges = []
         | 
| 149 | 
            +
             | 
| 150 | 
            +
                  count = product_price[:price_ranges][:total_elements].to_i
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                  (0..count - 1).each do|i|
         | 
| 153 | 
            +
                    price_range = product_price[:price_ranges][:priceranges][i]
         | 
| 154 | 
            +
             | 
| 155 | 
            +
                    price_ranges << {
         | 
| 156 | 
            +
                      priceRange: {
         | 
| 157 | 
            +
                        quantityBeginRange: price_range[:quantity_begin_range],
         | 
| 158 | 
            +
                        price: price_range[:price],
         | 
| 159 | 
            +
                        level: price_range[:level],
         | 
| 160 | 
            +
                        eid: price_range[:eid]
         | 
| 161 | 
            +
                      }
         | 
| 162 | 
            +
                    }
         | 
| 163 | 
            +
                  end
         | 
| 164 | 
            +
             | 
| 165 | 
            +
                  price_ranges
         | 
| 166 | 
            +
                end
         | 
| 167 | 
            +
             | 
| 168 | 
            +
                def get_page_info(category)
         | 
| 169 | 
            +
                  {
         | 
| 170 | 
            +
                    pageNumber: category[:page_number],
         | 
| 171 | 
            +
                    pageSize: category[:page_size],
         | 
| 172 | 
            +
                    totalElements: category[:total_elements],
         | 
| 173 | 
            +
                    elementCount: category[:element_count],
         | 
| 174 | 
            +
                    totalPages: category[:total_pages]
         | 
| 175 | 
            +
                  }
         | 
| 176 | 
            +
                end
         | 
| 177 | 
            +
             | 
| 178 | 
            +
                def get_billing_account(billing_account)
         | 
| 179 | 
            +
                  ba_details = {
         | 
| 180 | 
            +
                    attributes: {
         | 
| 181 | 
            +
                      accountNum: billing_account[:account_num],
         | 
| 182 | 
            +
                      billType: billing_account[:bill_type],
         | 
| 183 | 
            +
                      automaticRecurringPayment: billing_account[:automatic_recurring_payment],
         | 
| 184 | 
            +
                      status: billing_account[:status],
         | 
| 185 | 
            +
                      pendingChargesTotal: billing_account[:pending_charges_total],
         | 
| 186 | 
            +
                      balance: billing_account[:balance],
         | 
| 187 | 
            +
                      startDate: billing_account[:start_date],
         | 
| 188 | 
            +
                      taxExempt: billing_account[:tax_exempt],
         | 
| 189 | 
            +
                      eid: billing_account[:eid]
         | 
| 190 | 
            +
                    },
         | 
| 191 | 
            +
                    dailyBillCycle: {
         | 
| 192 | 
            +
                      name: billing_account[:daily_bill_cycle][:name],
         | 
| 193 | 
            +
                      startDate: billing_account[:daily_bill_cycle][:start_date],
         | 
| 194 | 
            +
                      endDate: billing_account[:daily_bill_cycle][:end_date],
         | 
| 195 | 
            +
                      billCycleType: billing_account[:daily_bill_cycle][:bill_cycle_type],
         | 
| 196 | 
            +
                      autoBill: billing_account[:daily_bill_cycle][:auto_bill],
         | 
| 197 | 
            +
                      usePaymentTerm: billing_account[:daily_bill_cycle][:use_payment_term],
         | 
| 198 | 
            +
                      status: billing_account[:daily_bill_cycle][:status],
         | 
| 199 | 
            +
                      eid: billing_account[:daily_bill_cycle][:eid]
         | 
| 200 | 
            +
                    },
         | 
| 201 | 
            +
                    person: {
         | 
| 202 | 
            +
                      attributes: {
         | 
| 203 | 
            +
                        firstName: billing_account[:person][:first_name],
         | 
| 204 | 
            +
                        lastName: billing_account[:person][:last_name],
         | 
| 205 | 
            +
                        eid: billing_account[:person][:eid]
         | 
| 206 | 
            +
                      },
         | 
| 207 | 
            +
                      addresses: get_addresses(billing_account[:person])
         | 
| 208 | 
            +
                    },
         | 
| 209 | 
            +
                    billingAccountCategory: {
         | 
| 210 | 
            +
                      type: billing_account[:billing_account_category][:type],
         | 
| 211 | 
            +
                      description: billing_account[:billing_account_category][:description],
         | 
| 212 | 
            +
                      status: billing_account[:billing_account_category][:status],
         | 
| 213 | 
            +
                      eid: billing_account[:billing_account_category][:eid]
         | 
| 214 | 
            +
                    },
         | 
| 215 | 
            +
                    paymentTerm: {
         | 
| 216 | 
            +
                      name: billing_account[:payment_term][:name],
         | 
| 217 | 
            +
                      termDays: billing_account[:payment_term][:term_days],
         | 
| 218 | 
            +
                      graceDays: billing_account[:payment_term][:grace_days],
         | 
| 219 | 
            +
                      eid: billing_account[:payment_term][:eid]
         | 
| 220 | 
            +
                    }
         | 
| 221 | 
            +
                  }
         | 
| 222 | 
            +
             | 
| 223 | 
            +
                  ba_details
         | 
| 224 | 
            +
                end
         | 
| 225 | 
            +
             | 
| 226 | 
            +
                def get_addresses(entity)
         | 
| 227 | 
            +
                  addresses = {
         | 
| 228 | 
            +
                    attributes: {},
         | 
| 229 | 
            +
                    emailAddress: {
         | 
| 230 | 
            +
                      purpose: entity[:addresses][:email_address][:purpose],
         | 
| 231 | 
            +
                      email: entity[:addresses][:email_address][:email],
         | 
| 232 | 
            +
                      eid: entity[:addresses][:email_address][:eid] || ''
         | 
| 233 | 
            +
                    },
         | 
| 234 | 
            +
                    postalAddress: {
         | 
| 235 | 
            +
                      purpose: entity[:addresses][:postal_address][:purpose],
         | 
| 236 | 
            +
                      country: entity[:addresses][:postal_address][:country],
         | 
| 237 | 
            +
                      city: entity[:addresses][:postal_address][:city],
         | 
| 238 | 
            +
                      regionOrState: entity[:addresses][:postal_address][:region_or_state],
         | 
| 239 | 
            +
                      attention: entity[:addresses][:postal_address][:attention],
         | 
| 240 | 
            +
                      postalCode: entity[:addresses][:postal_address][:postal_code],
         | 
| 241 | 
            +
                      line1: entity[:addresses][:postal_address][:line1],
         | 
| 242 | 
            +
                      eid: entity[:addresses][:postal_address][:eid] || ''
         | 
| 243 | 
            +
                    },
         | 
| 244 | 
            +
                    telecomAddress: {
         | 
| 245 | 
            +
                      dialingPrefix: entity[:addresses][:telecom_address][:dialing_prefix],
         | 
| 246 | 
            +
                      countryCode: entity[:addresses][:telecom_address][:country_code],
         | 
| 247 | 
            +
                      areaCode: entity[:addresses][:telecom_address][:area_code],
         | 
| 248 | 
            +
                      number: entity[:addresses][:telecom_address][:number],
         | 
| 249 | 
            +
                      extension: entity[:addresses][:telecom_address][:extension],
         | 
| 250 | 
            +
                      purpose: entity[:addresses][:telecom_address][:purpose],
         | 
| 251 | 
            +
                      eid: entity[:addresses][:telecom_address][:eid] || ''
         | 
| 252 | 
            +
                    }
         | 
| 253 | 
            +
                  }
         | 
| 254 | 
            +
             | 
| 255 | 
            +
                  addresses.each{|k,v| v.delete_if{|tags,data| data == ''}}
         | 
| 256 | 
            +
                end
         | 
| 257 | 
            +
             | 
| 258 | 
            +
              end
         | 
| 259 | 
            +
            end
         | 
| @@ -53,7 +53,17 @@ module GoTransverseTractApi | |
| 53 53 | 
             
                    # @param {Hash} adjustment
         | 
| 54 54 | 
             
                    #
         | 
| 55 55 | 
             
                    def post eid, adjustment
         | 
| 56 | 
            -
                       | 
| 56 | 
            +
                      data = {
         | 
| 57 | 
            +
                        :postAdjustment => {},
         | 
| 58 | 
            +
                        :adjustment => {
         | 
| 59 | 
            +
                          :attributes => {
         | 
| 60 | 
            +
                            eid: adjustment[:eid]
         | 
| 61 | 
            +
                          }
         | 
| 62 | 
            +
                        }
         | 
| 63 | 
            +
                      }
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                      xml_data = GoTransverseTractApi.generateXML(data, 'postAdjustment')
         | 
| 66 | 
            +
                      GoTransverseTractApi.post_request_for(self, {eid: eid}, xml_data, "post")
         | 
| 57 67 | 
             
                    end
         | 
| 58 68 |  | 
| 59 69 | 
             
                    #
         | 
| @@ -61,7 +71,15 @@ module GoTransverseTractApi | |
| 61 71 | 
             
                    # @param {Hash} adjustment
         | 
| 62 72 | 
             
                    #
         | 
| 63 73 | 
             
                    def reverse eid, adjustment
         | 
| 64 | 
            -
                       | 
| 74 | 
            +
                      data = {
         | 
| 75 | 
            +
                        :reverseAdjustment => {
         | 
| 76 | 
            +
                          :fullAmount => adjustment[:full_amount]
         | 
| 77 | 
            +
                        },
         | 
| 78 | 
            +
                        :adjustment => make_adjustment(adjustment)
         | 
| 79 | 
            +
                      }
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                      xml_data = GoTransverseTractApi.generateXML(data, 'reverseAdjustment')
         | 
| 82 | 
            +
                      GoTransverseTractApi.post_request_for(self, {eid: eid}, xml_data, "reverse")
         | 
| 65 83 | 
             
                    end
         | 
| 66 84 |  | 
| 67 85 | 
             
                    #
         | 
| @@ -69,7 +87,23 @@ module GoTransverseTractApi | |
| 69 87 | 
             
                    # @param {Hash} adjustment
         | 
| 70 88 | 
             
                    #
         | 
| 71 89 | 
             
                    def add_invoice_application eid, adjustment
         | 
| 72 | 
            -
             | 
| 90 | 
            +
             | 
| 91 | 
            +
                      account_adjustment = make_adjustment(adjustment)
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                      data = {
         | 
| 94 | 
            +
                        :addInvoiceApplicationToAdjustment => {},
         | 
| 95 | 
            +
                        :adjustment => account_adjustment,
         | 
| 96 | 
            +
                        :invoiceAdjustmentApplication => {
         | 
| 97 | 
            +
                          :attributes => {
         | 
| 98 | 
            +
                            :amount => adjustment[:invoice_adjustment_application][:amount]
         | 
| 99 | 
            +
                          },
         | 
| 100 | 
            +
                          :accountAdjustment => account_adjustment,
         | 
| 101 | 
            +
                          :invoice => get_invoice(adjustment, account_adjustment)
         | 
| 102 | 
            +
                        }
         | 
| 103 | 
            +
                      }
         | 
| 104 | 
            +
             | 
| 105 | 
            +
                      xml_data = GoTransverseTractApi.generateXML(data, 'addInvoiceApplicationToAdjustment')
         | 
| 106 | 
            +
                      GoTransverseTractApi.post_request_for(self, {eid: eid}, xml_data, "addInvoiceApplication")
         | 
| 73 107 | 
             
                    end
         | 
| 74 108 |  | 
| 75 109 | 
             
                    #
         | 
| @@ -77,14 +111,180 @@ module GoTransverseTractApi | |
| 77 111 | 
             
                    # @param {Hash} adjustment
         | 
| 78 112 | 
             
                    #
         | 
| 79 113 | 
             
                    def reverse_invoice_application eid, adjustment
         | 
| 80 | 
            -
             | 
| 114 | 
            +
             | 
| 115 | 
            +
                      account_adjustment = make_adjustment(adjustment)
         | 
| 116 | 
            +
             | 
| 117 | 
            +
                      data = {
         | 
| 118 | 
            +
                        :reverseInvoiceApplicationFromAdjustment => {},
         | 
| 119 | 
            +
                        :adjustment => account_adjustment,
         | 
| 120 | 
            +
                        :invoiceAdjustmentApplication => {
         | 
| 121 | 
            +
                          :attributes => {
         | 
| 122 | 
            +
                            :reversed => adjustment[:invoice_adjustment_application][:reversed],
         | 
| 123 | 
            +
                            :appliedOn => adjustment[:invoice_adjustment_application][:applied_on],
         | 
| 124 | 
            +
                            :amount => adjustment[:invoice_adjustment_application][:amount],
         | 
| 125 | 
            +
                            eid: adjustment[:invoice_adjustment_application][:eid]
         | 
| 126 | 
            +
                          },
         | 
| 127 | 
            +
                          :accountAdjustment => {
         | 
| 128 | 
            +
                            :attributes => {
         | 
| 129 | 
            +
                              :occurredOn => adjustment[:occurred_on],
         | 
| 130 | 
            +
                              :amount => adjustment[:amount],
         | 
| 131 | 
            +
                              :description => adjustment[:description],
         | 
| 132 | 
            +
                              :invoiced => adjustment[:invoice_adjustment_application][:account_adjustment][:invoiced],
         | 
| 133 | 
            +
                              :credit => adjustment[:invoice_adjustment_application][:account_adjustment][:credit],
         | 
| 134 | 
            +
                              :status => adjustment[:invoice_adjustment_application][:account_adjustment][:status],
         | 
| 135 | 
            +
                              :type => adjustment[:type],
         | 
| 136 | 
            +
                              :posted_on => adjustment[:invoice_adjustment_application][:account_adjustment][:posted_on],
         | 
| 137 | 
            +
                              :posted_by => adjustment[:invoice_adjustment_application][:account_adjustment][:posted_by],
         | 
| 138 | 
            +
                              :manualInvoiceApplication => adjustment[:manual_invoice_application],
         | 
| 139 | 
            +
                              eid: adjustment[:eid]
         | 
| 140 | 
            +
                            },
         | 
| 141 | 
            +
                            :billingAccount => account_adjustment[:billingAccount],
         | 
| 142 | 
            +
                            :reason => account_adjustment[:reason],
         | 
| 143 | 
            +
                            :adjustmentApplications => account_adjustment[:billingAccount][:services]
         | 
| 144 | 
            +
                          },
         | 
| 145 | 
            +
                          :invoice => get_invoice(adjustment, account_adjustment)
         | 
| 146 | 
            +
                        }
         | 
| 147 | 
            +
                      }
         | 
| 148 | 
            +
             | 
| 149 | 
            +
                      xml_data = GoTransverseTractApi.generateXML(data, 'reverseInvoiceApplicationFromAdjustment')
         | 
| 150 | 
            +
                      GoTransverseTractApi.post_request_for(self, {eid: eid}, xml_data, "reverseInvoiceApplication")
         | 
| 81 151 | 
             
                    end
         | 
| 82 152 |  | 
| 83 153 | 
             
                    #
         | 
| 84 154 | 
             
                    # @param {Hash} adjustment
         | 
| 85 155 | 
             
                    #
         | 
| 86 156 | 
             
                    def create_adjustment adjustment
         | 
| 87 | 
            -
             | 
| 157 | 
            +
             | 
| 158 | 
            +
                      data = {
         | 
| 159 | 
            +
                        :adjustment => {
         | 
| 160 | 
            +
                          :occurredOn => adjustment[:occurred_on],
         | 
| 161 | 
            +
                          :amount => adjustment[:amount],
         | 
| 162 | 
            +
                          :description => adjustment[:description],
         | 
| 163 | 
            +
                          :type => adjustment[:type],
         | 
| 164 | 
            +
                          :credit => adjustment[:credit],
         | 
| 165 | 
            +
                          :posted => adjustment[:posted]
         | 
| 166 | 
            +
                        },
         | 
| 167 | 
            +
                        :billingAccount => {
         | 
| 168 | 
            +
                          eid: adjustment[:billing_account][:eid]
         | 
| 169 | 
            +
                        },
         | 
| 170 | 
            +
                        :reason => {
         | 
| 171 | 
            +
                          eid: adjustment[:reason][:eid]
         | 
| 172 | 
            +
                        }
         | 
| 173 | 
            +
                      }
         | 
| 174 | 
            +
             | 
| 175 | 
            +
                      xml_data = GoTransverseTractApi.generateXML(data, 'adjustment')
         | 
| 176 | 
            +
                      GoTransverseTractApi.post_request_for(self, {}, xml_data, "")
         | 
| 177 | 
            +
                    end
         | 
| 178 | 
            +
             | 
| 179 | 
            +
                    private
         | 
| 180 | 
            +
             | 
| 181 | 
            +
                    def get_invoice (adjustment, account_adjustment)
         | 
| 182 | 
            +
                      {
         | 
| 183 | 
            +
                        :attributes => {
         | 
| 184 | 
            +
                          :invoiceNum => adjustment[:invoice_adjustment_application][:invoice][:invoice_num],
         | 
| 185 | 
            +
                          :amount => adjustment[:invoice_adjustment_application][:invoice][:amount],
         | 
| 186 | 
            +
                          :pdfPath => adjustment[:invoice_adjustment_application][:invoice][:pdf_path],
         | 
| 187 | 
            +
                          :occurredOn => adjustment[:invoice_adjustment_application][:invoice][:occurred_on],
         | 
| 188 | 
            +
                          :dueDate => adjustment[:invoice_adjustment_application][:invoice][:due_date],
         | 
| 189 | 
            +
                          :amountToPay => adjustment[:invoice_adjustment_application][:invoice][:amount_to_pay],
         | 
| 190 | 
            +
                          :lateFeeCharged => adjustment[:invoice_adjustment_application][:invoice][:late_fee_charged],
         | 
| 191 | 
            +
                          :status => adjustment[:invoice_adjustment_application][:invoice][:status],
         | 
| 192 | 
            +
                          :usageCsvPath => adjustment[:invoice_adjustment_application][:invoice][:usage_csv_path],
         | 
| 193 | 
            +
                          eid: adjustment[:invoice_adjustment_application][:invoice][:eid]
         | 
| 194 | 
            +
                        },
         | 
| 195 | 
            +
                        :billingAccount => account_adjustment[:billingAccount],
         | 
| 196 | 
            +
                        :billCycle => account_adjustment[:billingAccount][:dailyBillCycle],
         | 
| 197 | 
            +
                        :invoiceItems => account_adjustment[:billingAccount][:services]
         | 
| 198 | 
            +
                      }
         | 
| 199 | 
            +
                    end
         | 
| 200 | 
            +
             | 
| 201 | 
            +
                    def make_adjustment adjustment
         | 
| 202 | 
            +
                      adjustment = {
         | 
| 203 | 
            +
                        :attributes => {
         | 
| 204 | 
            +
                          :occurredOn => adjustment[:occurred_on],
         | 
| 205 | 
            +
                          :amount => adjustment[:amount],
         | 
| 206 | 
            +
                          :description => adjustment[:description],
         | 
| 207 | 
            +
                          :invoiced => adjustment[:invoiced],
         | 
| 208 | 
            +
                          :credit => adjustment[:credit],
         | 
| 209 | 
            +
                          :status => adjustment[:status],
         | 
| 210 | 
            +
                          :type => adjustment[:type],
         | 
| 211 | 
            +
                          :manualInvoiceApplication => adjustment[:manual_invoice_application],
         | 
| 212 | 
            +
                          eid: adjustment[:eid]
         | 
| 213 | 
            +
                        },
         | 
| 214 | 
            +
                        :billingAccount => {
         | 
| 215 | 
            +
                          :attributes => {
         | 
| 216 | 
            +
                            :accountNum => adjustment[:billing_account][:account_num],
         | 
| 217 | 
            +
                            :billType => adjustment[:billing_account][:bill_type],
         | 
| 218 | 
            +
                            :automaticRecurringPayment => adjustment[:billing_account][:automatic_recurring_payment],
         | 
| 219 | 
            +
                            :status => adjustment[:billing_account][:status],
         | 
| 220 | 
            +
                            :pendingChargesTotal => adjustment[:billing_account][:pending_charges_total],
         | 
| 221 | 
            +
                            :balance => adjustment[:billing_account][:balance],
         | 
| 222 | 
            +
                            :startDate => adjustment[:billing_account][:start_date],
         | 
| 223 | 
            +
                            :taxExempt => adjustment[:billing_account][:tax_exempt],
         | 
| 224 | 
            +
                            eid: adjustment[:billing_account][:eid]
         | 
| 225 | 
            +
                          },
         | 
| 226 | 
            +
                          :dailyBillCycle => {
         | 
| 227 | 
            +
                            :name => adjustment[:billing_account][:daily_bill_cycle][:name],
         | 
| 228 | 
            +
                            :startDate => adjustment[:billing_account][:daily_bill_cycle][:start_date],
         | 
| 229 | 
            +
                            :endDate => adjustment[:billing_account][:daily_bill_cycle][:end_date],
         | 
| 230 | 
            +
                            :billCycleType => adjustment[:billing_account][:daily_bill_cycle][:bill_cycle_type],
         | 
| 231 | 
            +
                            :autoBill => adjustment[:billing_account][:daily_bill_cycle][:auto_bill],
         | 
| 232 | 
            +
                            :usePaymentTerm => adjustment[:billing_account][:daily_bill_cycle][:use_payment_term],
         | 
| 233 | 
            +
                            :status => adjustment[:billing_account][:daily_bill_cycle][:status],
         | 
| 234 | 
            +
                            eid: adjustment[:billing_account][:daily_bill_cycle][:eid]
         | 
| 235 | 
            +
                          },
         | 
| 236 | 
            +
                          :person => {
         | 
| 237 | 
            +
                            :attributes => {
         | 
| 238 | 
            +
                              :firstName => adjustment[:billing_account][:person][:first_name],
         | 
| 239 | 
            +
                              :lastName => adjustment[:billing_account][:person][:last_name],
         | 
| 240 | 
            +
                              eid: adjustment[:billing_account][:person][:eid]
         | 
| 241 | 
            +
                            },
         | 
| 242 | 
            +
                            :addresses => {
         | 
| 243 | 
            +
                              :attributes => {},
         | 
| 244 | 
            +
                              :postalAddress => {
         | 
| 245 | 
            +
                                :purpose => adjustment[:billing_account][:person][:addresses][:postal_address][:purpose],
         | 
| 246 | 
            +
                                :country => adjustment[:billing_account][:person][:addresses][:postal_address][:country],
         | 
| 247 | 
            +
                                :city => adjustment[:billing_account][:person][:addresses][:postal_address][:city],
         | 
| 248 | 
            +
                                :regionOrState => adjustment[:billing_account][:person][:addresses][:postal_address][:region_or_state],
         | 
| 249 | 
            +
                                :postalCode => adjustment[:billing_account][:person][:addresses][:postal_address][:postal_code],
         | 
| 250 | 
            +
                                :line1 => adjustment[:billing_account][:person][:addresses][:postal_address][:line1],
         | 
| 251 | 
            +
                                eid: adjustment[:billing_account][:person][:addresses][:postal_address][:eid]
         | 
| 252 | 
            +
                              },
         | 
| 253 | 
            +
                              :emailAddress => {
         | 
| 254 | 
            +
                                :purpose => adjustment[:billing_account][:person][:addresses][:email_address][:purpose],
         | 
| 255 | 
            +
                                :email => adjustment[:billing_account][:person][:addresses][:email_address][:email],
         | 
| 256 | 
            +
                                eid: adjustment[:billing_account][:person][:addresses][:email_address][:eid]
         | 
| 257 | 
            +
                              }
         | 
| 258 | 
            +
                            }
         | 
| 259 | 
            +
                          },
         | 
| 260 | 
            +
                          :billingAccountCategory => {
         | 
| 261 | 
            +
                            :type => adjustment[:billing_account][:billing_account_category][:type],
         | 
| 262 | 
            +
                            :description => adjustment[:billing_account][:billing_account_category][:description],
         | 
| 263 | 
            +
                            :status => adjustment[:billing_account][:billing_account_category][:status],
         | 
| 264 | 
            +
                            eid: adjustment[:billing_account][:billing_account_category][:eid]
         | 
| 265 | 
            +
                          },
         | 
| 266 | 
            +
                          :services => {
         | 
| 267 | 
            +
                            :pageNumber => adjustment[:billing_account][:services][:page_number],
         | 
| 268 | 
            +
                            :pageSize => adjustment[:billing_account][:services][:page_size],
         | 
| 269 | 
            +
                            :totalElements => adjustment[:billing_account][:services][:total_elements],
         | 
| 270 | 
            +
                            :elementCount => adjustment[:billing_account][:services][:element_count],
         | 
| 271 | 
            +
                            :totalPages => adjustment[:billing_account][:services][:total_pages]
         | 
| 272 | 
            +
                          },
         | 
| 273 | 
            +
                          :paymentTerm => {
         | 
| 274 | 
            +
                            :name => adjustment[:billing_account][:payment_term][:name],
         | 
| 275 | 
            +
                            :termDays => adjustment[:billing_account][:payment_term][:term_days],
         | 
| 276 | 
            +
                            :graceDays => adjustment[:billing_account][:payment_term][:grace_days],
         | 
| 277 | 
            +
                            eid: adjustment[:billing_account][:payment_term][:eid]
         | 
| 278 | 
            +
                          }
         | 
| 279 | 
            +
                        },
         | 
| 280 | 
            +
                        :reason => {
         | 
| 281 | 
            +
                          :name => adjustment[:reason][:name],
         | 
| 282 | 
            +
                          :description => adjustment[:reason][:description],
         | 
| 283 | 
            +
                          :status => adjustment[:reason][:status],
         | 
| 284 | 
            +
                          :creditOnly => adjustment[:reason][:credit_only],
         | 
| 285 | 
            +
                          eid: adjustment[:reason][:eid]
         | 
| 286 | 
            +
                        }
         | 
| 287 | 
            +
                      }
         | 
| 88 288 | 
             
                    end
         | 
| 89 289 |  | 
| 90 290 | 
             
                  end
         |