kounta_rest 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kounta/company.rb +2 -0
- data/lib/kounta/person.rb +27 -0
- data/lib/kounta/version.rb +1 -1
- data/lib/kounta.rb +1 -0
- data/spec/fixtures/people.json +20 -0
- data/spec/fixtures/person.json +41 -0
- data/spec/kounta/person_spec.rb +15 -0
- data/spec/support/endpoints.rb +4 -0
- metadata +8 -1
data/lib/kounta/company.rb
CHANGED
@@ -19,6 +19,7 @@ module Kounta
|
|
19
19
|
has_one :product, Kounta::Product, {:company_id => :id}, lambda { |klass, item_id| {companies: klass.id, products: item_id} }
|
20
20
|
has_one :category, Kounta::Category, {:company_id => :id}, lambda { |klass, item_id| {companies: klass.id, categories: item_id} }
|
21
21
|
has_one :customer, Kounta::Customer, {:company_id => :id}, lambda { |klass, item_id| {companies: klass.id, customers: item_id} }
|
22
|
+
has_one :person, Kounta::Person, {:company_id => :id}, lambda { |klass, item_id| {companies: klass.id, people: item_id} }
|
22
23
|
has_one :site, Kounta::Site, {:company_id => :id}, lambda { |klass, item_id| {companies: klass.id, sites: item_id} }
|
23
24
|
has_one :price_list, Kounta::PriceList, {:company_id => :id}, lambda { |klass, item_id| {companies: klass.id, price_lists: item_id} }
|
24
25
|
has_one :tax, Kounta::Tax, {:company_id => :id}, lambda { |klass, item_id| {companies: klass.id, taxes: item_id} }
|
@@ -26,6 +27,7 @@ module Kounta
|
|
26
27
|
has_many :products, Kounta::Product, {:company_id => :id}, lambda { |klass| {companies: klass.id, products: nil} }
|
27
28
|
has_many :categories, Kounta::Category, {:company_id => :id}, lambda { |klass| {companies: klass.id, categories: nil} }
|
28
29
|
has_many :customers, Kounta::Customer, {:company_id => :id}, lambda { |klass| {companies: klass.id, customers: nil} }
|
30
|
+
has_many :people, Kounta::Person, {:company_id => :id}, lambda { |klass| {companies: klass.id, people: nil} }
|
29
31
|
has_many :sites, Kounta::Site, {:company_id => :id}, lambda { |klass| {companies: klass.id, sites: nil} }
|
30
32
|
has_many :price_lists, Kounta::PriceList, {:company_id => :id}, lambda { |klass| {companies: klass.id, price_lists: nil} }
|
31
33
|
has_many :taxes, Kounta::Tax, {:company_id => :id}, lambda { |klass| {companies: klass.id, taxes: nil} }
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Kounta
|
2
|
+
|
3
|
+
class Person < Kounta::Resource
|
4
|
+
property :company_id
|
5
|
+
property :customer_id
|
6
|
+
property :staff_id
|
7
|
+
property :first_name
|
8
|
+
property :last_name
|
9
|
+
property :primary_email_address
|
10
|
+
property :email_addresses
|
11
|
+
property :shipping_address
|
12
|
+
property :postal_address
|
13
|
+
property :addresses
|
14
|
+
property :phone_numbers
|
15
|
+
property :image
|
16
|
+
|
17
|
+
def name
|
18
|
+
"#{first_name} #{last_name}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def resource_path
|
22
|
+
{companies: company_id, people: id}
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/kounta/version.rb
CHANGED
data/lib/kounta.rb
CHANGED
@@ -9,6 +9,7 @@ require_relative "kounta/address"
|
|
9
9
|
require_relative "kounta/payment"
|
10
10
|
require_relative "kounta/line"
|
11
11
|
require_relative "kounta/order"
|
12
|
+
require_relative "kounta/person"
|
12
13
|
require_relative "kounta/customer"
|
13
14
|
require_relative "kounta/price_list"
|
14
15
|
require_relative "kounta/site"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": 701892,
|
4
|
+
"first_name": "Jamie",
|
5
|
+
"last_name": "McDonald",
|
6
|
+
"customer_id": 389427,
|
7
|
+
"staff_id": null,
|
8
|
+
"primary_email_address": "jamie@kounta.kom",
|
9
|
+
"image": "http://www.gravatar.com/avatar/cc6f3f16c233257d437ea5163787645e.jpg"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"id": 742890,
|
13
|
+
"first_name": "Jim",
|
14
|
+
"last_name": "Bluth",
|
15
|
+
"customer_id": null,
|
16
|
+
"staff_id": 3012,
|
17
|
+
"primary_email_address": "jim@kounta.kom",
|
18
|
+
"image": null
|
19
|
+
}
|
20
|
+
]
|
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"id": 701892,
|
3
|
+
"first_name": "Jamie",
|
4
|
+
"last_name": "McDonald",
|
5
|
+
"customer_id": 389427,
|
6
|
+
"staff_id": null,
|
7
|
+
"primary_email_address": "jamie@kounta.kom",
|
8
|
+
"email_addresses": [
|
9
|
+
"jamie@kounta.kom",
|
10
|
+
"jamie112783@hotmail.kom"
|
11
|
+
],
|
12
|
+
"shipping_address": {
|
13
|
+
"id": 198109,
|
14
|
+
"lines": [
|
15
|
+
"Suite 5, Level 12",
|
16
|
+
"44 Mutton Street"
|
17
|
+
],
|
18
|
+
"city": "Beeftown",
|
19
|
+
"zone": "NSW",
|
20
|
+
"postal_code": "2112",
|
21
|
+
"country": "AU"
|
22
|
+
},
|
23
|
+
"postal_address": null,
|
24
|
+
"addresses": {
|
25
|
+
"count": 3,
|
26
|
+
"updated_at": "2013-05-22T16:21:40+10:00"
|
27
|
+
},
|
28
|
+
"phone_numbers": [
|
29
|
+
{
|
30
|
+
"label": "Phone",
|
31
|
+
"number": "(02) 9876 5432"
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"label": "Mobile",
|
35
|
+
"number": "0405 060 708"
|
36
|
+
}
|
37
|
+
],
|
38
|
+
"image": "http://www.gravatar.com/avatar/cc6f3f16c233257d437ea5163787645e.jpg",
|
39
|
+
"created_at": "2013-05-08T13:56:02+10:00",
|
40
|
+
"updated_at": "2013-05-22T16:21:40+10:00"
|
41
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
describe Kounta::Person do
|
4
|
+
|
5
|
+
subject { Kounta::Company.new.person(701892) }
|
6
|
+
|
7
|
+
it "should have a name" do
|
8
|
+
subject.name.should eq("Jamie McDonald")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should have a resource path" do
|
12
|
+
subject.resource_path.should eq({companies: 162, people: 701892})
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/spec/support/endpoints.rb
CHANGED
@@ -29,6 +29,7 @@ module Helpers
|
|
29
29
|
# create
|
30
30
|
stub_request(:post, group_endpoint('products')).to_return(:body => load_json_from_fixture('product.json'), :headers => endpoint_headers)
|
31
31
|
stub_request(:post, group_endpoint('customers')).to_return(:body => load_json_from_fixture('customer.json'), :headers => endpoint_headers)
|
32
|
+
stub_request(:post, group_endpoint('people')).to_return(:body => load_json_from_fixture('person.json'), :headers => endpoint_headers)
|
32
33
|
stub_request(:post, group_endpoint('categories')).to_return(:body => load_json_from_fixture('category.json'), :headers => endpoint_headers)
|
33
34
|
stub_request(:post, group_endpoint('addresses')).to_return(:body => load_json_from_fixture('address.json'), :headers => endpoint_headers)
|
34
35
|
stub_request(:post, group_endpoint('payments')).to_return(:body => load_json_from_fixture('payment.json'), :headers => endpoint_headers)
|
@@ -40,6 +41,8 @@ module Helpers
|
|
40
41
|
stub_request(:get, group_endpoint('categories')).to_return(:body => load_json_from_fixture('categories.json'), :headers => endpoint_headers)
|
41
42
|
stub_request(:get, singular_endpoint('customers')).to_return(:body => load_json_from_fixture('customer.json'), :headers => endpoint_headers)
|
42
43
|
stub_request(:get, group_endpoint('customers')).to_return(:body => load_json_from_fixture('customers.json'), :headers => endpoint_headers)
|
44
|
+
stub_request(:get, singular_endpoint('people')).to_return(:body => load_json_from_fixture('person.json'), :headers => endpoint_headers)
|
45
|
+
stub_request(:get, group_endpoint('people')).to_return(:body => load_json_from_fixture('people.json'), :headers => endpoint_headers)
|
43
46
|
stub_request(:get, singular_endpoint('addresses')).to_return(:body => load_json_from_fixture('address.json'), :headers => endpoint_headers)
|
44
47
|
stub_request(:get, group_endpoint('addresses')).to_return(:body => load_json_from_fixture('addresses.json'), :headers => endpoint_headers)
|
45
48
|
stub_request(:get, singular_endpoint('products')).to_return(:body => load_json_from_fixture('product.json'), :headers => endpoint_headers)
|
@@ -57,6 +60,7 @@ module Helpers
|
|
57
60
|
# update
|
58
61
|
stub_request(:put, singular_endpoint('products')).to_return(:body => load_json_from_fixture('product.json'), :headers => endpoint_headers)
|
59
62
|
stub_request(:put, singular_endpoint('customers')).to_return(:body => load_json_from_fixture('customer.json'), :headers => endpoint_headers)
|
63
|
+
stub_request(:put, singular_endpoint('people')).to_return(:body => load_json_from_fixture('person.json'), :headers => endpoint_headers)
|
60
64
|
stub_request(:put, singular_endpoint('categories')).to_return(:body => load_json_from_fixture('category.json'), :headers => endpoint_headers)
|
61
65
|
stub_request(:put, singular_endpoint('addresses')).to_return(:body => load_json_from_fixture('address.json'), :headers => endpoint_headers)
|
62
66
|
stub_request(:put, singular_endpoint('payments')).to_return(:body => load_json_from_fixture('payment.json'), :headers => endpoint_headers)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kounta_rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- lib/kounta/line.rb
|
196
196
|
- lib/kounta/order.rb
|
197
197
|
- lib/kounta/payment.rb
|
198
|
+
- lib/kounta/person.rb
|
198
199
|
- lib/kounta/price_list.rb
|
199
200
|
- lib/kounta/product.rb
|
200
201
|
- lib/kounta/resource.rb
|
@@ -214,6 +215,8 @@ files:
|
|
214
215
|
- spec/fixtures/order.json
|
215
216
|
- spec/fixtures/orders.json
|
216
217
|
- spec/fixtures/payment.json
|
218
|
+
- spec/fixtures/people.json
|
219
|
+
- spec/fixtures/person.json
|
217
220
|
- spec/fixtures/price_list.json
|
218
221
|
- spec/fixtures/price_lists.json
|
219
222
|
- spec/fixtures/product.json
|
@@ -231,6 +234,7 @@ files:
|
|
231
234
|
- spec/kounta/line_spec.rb
|
232
235
|
- spec/kounta/order_spec.rb
|
233
236
|
- spec/kounta/payment_spec.rb
|
237
|
+
- spec/kounta/person_spec.rb
|
234
238
|
- spec/kounta/product_spec.rb
|
235
239
|
- spec/kounta/resource_spec.rb
|
236
240
|
- spec/kounta/rest/client_spec.rb
|
@@ -274,6 +278,8 @@ test_files:
|
|
274
278
|
- spec/fixtures/order.json
|
275
279
|
- spec/fixtures/orders.json
|
276
280
|
- spec/fixtures/payment.json
|
281
|
+
- spec/fixtures/people.json
|
282
|
+
- spec/fixtures/person.json
|
277
283
|
- spec/fixtures/price_list.json
|
278
284
|
- spec/fixtures/price_lists.json
|
279
285
|
- spec/fixtures/product.json
|
@@ -291,6 +297,7 @@ test_files:
|
|
291
297
|
- spec/kounta/line_spec.rb
|
292
298
|
- spec/kounta/order_spec.rb
|
293
299
|
- spec/kounta/payment_spec.rb
|
300
|
+
- spec/kounta/person_spec.rb
|
294
301
|
- spec/kounta/product_spec.rb
|
295
302
|
- spec/kounta/resource_spec.rb
|
296
303
|
- spec/kounta/rest/client_spec.rb
|