-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProduct.m
63 lines (52 loc) · 1.4 KB
/
Product.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// Product.m
// Hitmeister API
//
// Created by Björn Kaiser on 29.06.12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "Product.h"
@interface Product()
- (NSString*) formatPrice:(int)price;
@end
@implementation Product
@synthesize item_title;
@synthesize ean;
@synthesize url;
@synthesize url_hitmeisterpartner;
@synthesize url_hitmeisteraffiliate;
@synthesize cheapest_price;
@synthesize cheapest_new_price;
@synthesize cheapest_used_price;
@synthesize shipping_cost_new;
@synthesize shipping_cost_used;
@synthesize listprice_savings;
@synthesize commission_category;
- (NSString*) getCheapestPriceFormatted
{
return [self formatPrice:self.cheapest_price];
}
- (NSString*) getCheapestNewPriceFormatted
{
return [self formatPrice:self.cheapest_new_price];
}
- (NSString*) getCheapestUsedPriceFormatted
{
return [self formatPrice:self.cheapest_used_price];
}
- (NSString*) getShippingCostUsedFormatted
{
return [self formatPrice:self.shipping_cost_used];
}
- (NSString*) getShippingCostNewFormatted
{
return [self formatPrice:self.shipping_cost_new];
}
- (NSString*) formatPrice:(int)price
{
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"de_DE"]];
return [formatter stringFromNumber:[NSNumber numberWithInt:(price/100)]];
}
@end